Conversation Search Operations#

Conversation search lets users find their own chats by title and message text. It is on by default. This page describes what the feature needs from the search engine, what an operator provides on managed clusters, and how to roll it back.

Notes for administrators

  • Search covers only a user’s own conversations in the project they are working in. Deleted, archived, incognito, and expiring conversations never appear in the results.

  • Search runs on the search engine of your Squirro deployment: Elasticsearch 9 or OpenSearch 3.9.0.

How It Works#

GenAI copies the text of each project’s conversations into the search engine, into one index per project named <prefix>_conversation_search_index_<project>. The prefix is the [index] search_index_name_prefix of the platform, squirro_v9 by default. A result shows the message text and snippet from that copy, and the platform checks the conversation itself against the database each time, so a conversation that was deleted or archived disappears at once.

The copy follows changes within a few seconds. After an upgrade, GenAI copies the existing conversations of each project in the background, in the order in which they last changed, oldest first. Until a project’s copy has caught up, its search results are flagged as incomplete and clients can show that.

During a rolling upgrade, the pods of the earlier release do not remove the copies of the conversations they delete. Those conversations never appear in search results, and GenAI removes their copies within five minutes of the deletion, once the pods of the new release run.

Every conversation index is on the cluster that [index] search_index_servers names. A project whose items are stored on another cluster, through an index server of its own, still has its conversation index on that default cluster.

GenAI connects to the search engine as its own user, squirro_conversations, on every deployment path. The user has a role that reaches only the <prefix>_conversation_search_index_* indices. It cannot read the indices of items, change templates, or touch the security settings. The platform installs the index template and creates the user, as described for each path below.

Index names use the lowercase form of the project ID. Project IDs that differ only in case share one index and one copy state, as item indices do. A project ID has conversation search only if, in lowercase, it consists of ASCII letters, digits, underscores, and hyphens and is at most 64 characters long. Projects with any other ID, such as legacy IDs that start with a comma or contain a dot, have no conversation search.

Deployment Paths#

Docker Compose. The one-shot search-users-init service applies the role on every start and creates the user if it does not exist, with the password from the file secrets/search_engine_genai_password.sec, which GenAI reads as well. It never changes the password of an existing user. See Changing the Password of GenAI’s User. See Upgrading an Existing Docker Compose Deployment and Managed Clusters.

RPM installations. The start script of the GenAI service generates a random password for the user once and keeps it in the file /etc/squirro/genai.d/squirro_conversations.password, which only the sqgenai user can read. On every start, the script passes that password to the container, applies the role, and creates the user if it does not exist, with the administrator credential in common.ini. It never changes the password of an existing user. That step runs in the background, so GenAI and chat start without waiting for the search engine, and its result appears in the log of the GenAI service once it ends. See Managed Clusters for a cluster on which that administrator cannot manage users.

On an installation with several cluster nodes that run GenAI, all nodes need the same password file, because the start never changes the password of an existing user. Start GenAI on one node first. After that start has created /etc/squirro/genai.d/squirro_conversations.password, copy the file to every other node before GenAI starts there for the first time, and keep the sqgenai owner and the mode 600.

A node whose file holds another password changes nothing on the search engine. Its start logs an ERROR, and searches on that node answer 503 until you fix the file:

  • The ERROR names another node. That node created the user. Copy the file from it to this node, keep the owner and the mode, and restart GenAI on this node.

  • The ERROR names no other node. The file on this node no longer holds the password of the user, for example because it was lost or replaced. Restore the file from a backup or from another GenAI node and restart GenAI, or give the user a new password as described in Changing the Password of GenAI’s User.

Managed clusters. On a cluster that Squirro does not administer, such as AWS OpenSearch Service, the user and the role may need to be created by hand. See Managed Clusters.

In all cases, GenAI reads its credential from the [index] search_auth_user and search_auth_password settings, which the container receives as the environment variables SQ_INDEX_SEARCH_AUTH_USER and SQ_INDEX_SEARCH_AUTH_PASSWORD. The [index] search_index_servers setting must name the cluster. For OpenSearch, GenAI also needs SQ_INDEX_SEARCH_ENGINE set to opensearch. See genai.ini.

Upgrading an Existing Docker Compose Deployment#

After you update the deployment files to this release, do the following steps once.

  1. Run ./ensure_secrets.sh from the deployment folder. It creates only the secrets that are missing, such as secrets/search_engine_genai_password.sec, which conversation search needs from this release on. Without that file, the stack does not start and Docker reports bind source path does not exist. make run-prod runs the script for you when a secret file is missing.

  2. On OpenSearch, recreate the searchengine container once, so that search-users-init can create the user. On Docker Compose, the container reads the setting that allows this only when it starts. That setting is plugins.security.restapi.roles_enabled: all_access, in runtime_variables/opensearch.env. It lets every holder of the shared administrator credential manage users and roles over the security REST API, which is what lets search-users-init create GenAI’s user. The squirro_containers Ansible role recreates the containers on every deployment, so with that role you do nothing. Without the role, run docker compose up -d --force-recreate searchengine. Until then, search-users-init fails with HTTP 403 and conversation searches answer 503. The rest of the platform is not affected.

Turning Search Off#

Set SQ_NEO_CONVERSATION_SEARCH_BACKEND to off and restart GenAI, which reads the setting only when it starts. Searches then answer with available: false and the conversation list tells clients that search is unavailable. GenAI still removes the copies of conversations that users delete, as long as the credential is in place.

The default value auto turns search on when search servers are configured and GenAI’s credential is usable. The value search_engine turns it on whatever the configuration says. Any other value stops GenAI from starting.

Missing or Refused Credentials#

The credential is missing. If [index] search_auth_user or search_auth_password is empty or cannot be read, search is off, and GenAI logs a warning at most once an hour that names what is missing and states how many deletions are waiting. GenAI does not queue new messages for copying, and it keeps every deletion waiting, however many there are. Once the credential is in place, the next cycle picks the deletions up and the copy catches up with all changes made since.

The search engine refuses the credential. GenAI logs one ERROR an hour that states how many changes are waiting and how old the oldest one is. Searches answer 503. Check that the user and role exist on the cluster and that the password GenAI holds is the password of that user. On Docker Compose, check that search-users-init completed. On RPM installations, the log of the GenAI service states whether the start created the user or found it with another password, and on an installation with several cluster nodes, every node must hold the same password file. On the first start of an RPM installation, and after the user was deleted, this ERROR can appear once before the start creates the user. Searches then work within seconds, and you do nothing. On Docker Compose with OpenSearch, the searchengine container must be recreated once after an upgrade, as described in Upgrading an Existing Docker Compose Deployment.

Index Template#

The platform installs the template for squirro_v9_conversation_search_index_* indices when the topic service starts, as it does for every other platform template. Two situations leave the template uninstalled:

  • The topic service installs no templates. This happens when topic.search.setup-on-startup is false. GenAI waits, logs one ERROR that the conversations template is missing, and searches answer 503 until the template is installed. Either set topic.search.setup-on-startup to true and restart the topic service once, or install the template yourself, as described next.

  • The index name prefix is not the default. Each platform template has a fixed pattern that starts with squirro_v9, so with a different [index] search_index_name_prefix no platform template matches. GenAI logs the same ERROR and searches answer 503 until you install a copy of the conversations template whose pattern is <prefix>_conversation_search_index_*. Item indices have the same limitation.

To make that copy, read the template from a cluster on which the platform installed it, change only the index pattern, and store it under a new name. Keep everything else, including the shard and replica settings and the _meta version: GenAI refuses an index whose version it does not expect.

  1. On such a cluster, run GET _index_template/squirro_v9_conversations and copy the index_template object of the answer.

  2. In that copy, replace the value of index_patterns with ["<prefix>_conversation_search_index_*"].

  3. On your cluster, run PUT _index_template/<prefix>_conversations with the changed copy as the body.

GenAI checks for the template again every five minutes. After the template is installed, searches can still answer 503 for up to five minutes, and the copies then fill in the background.

By default, the template sets one shard per index. With more shards, identical matches can score differently, and the order of the results can change.

To stop a stray write from creating a conversations index without the template, you can set action.auto_create_index on the cluster to refuse the pattern and allow the rest, for example -<prefix>_conversation_search_index_*,+*. If the setting already has a value, add the exclusion at its start. A list that holds only the exclusion stops the engine from auto-creating every other index. This guard is optional, and GenAI itself is not affected by it.

Managed Clusters#

A managed cluster needs the analysis-icu plugin, which the conversations template uses. Whether you create the user by hand depends on the deployment path.

RPM installations. On every start, the start script applies the role and creates the user if it does not exist, in the background, with the administrator credential in the [index] section of common.ini and the password in /etc/squirro/genai.d/squirro_conversations.password. If that administrator can manage users on the cluster, you do nothing. If it cannot, the log of the GenAI service shows a warning that names the exit code of the provisioning, and GenAI keeps running. Searches then answer 503 until the user exists. To create it by hand:

  1. Print the role that GenAI needs. The command contacts no search engine and needs no credentials. Run it in the GenAI container, with SQ_INDEX_SEARCH_INDEX_NAME_PREFIX set first if your prefix is not squirro_v9. Use opensearch or elasticsearch as the engine.

    python -m squirro.service.genai.v1.search.provision --print-role opensearch
    
  2. Read the password from /etc/squirro/genai.d/squirro_conversations.password, as root or as the sqgenai user. The start script creates the file on the first start with [index] search_index_servers set.

  3. Create the role and the user on the cluster, as described under Creating the Role and the User, with the password from step 2. Do not choose another password, because GenAI connects with the password in that file.

Docker Compose. When the user does not exist, the search-users-init service creates it with the password from secrets/search_engine_genai_password.sec. On a managed cluster, create the role and the user by hand, as described under Creating the Role and the User, with the content of that file as the password. Print the role with the command shown under RPM installations, or with docker compose run --rm --no-deps search-users-init python -m squirro.service.genai.v1.search.provision --print-role opensearch.

If topic.search.setup-on-startup is false, also install the conversations template as described in Index Template.

Creating the Role and the User#

The printed role is the only grant GenAI needs. It contains no cluster health permission.

  • OpenSearch. Create the role with a PUT to _plugins/_security/api/roles/squirro_conversations and the printed body. Map it to the user with a PUT to _plugins/_security/api/rolesmapping/squirro_conversations and the body {"users": ["squirro_conversations"]}. Create the user with a PUT to _plugins/_security/api/internalusers/squirro_conversations and the body {"password": "<password>"}.

  • Elasticsearch. Create the role with PUT _security/role/squirro_conversations and the printed body. Create the user with PUT _security/user/squirro_conversations and the body {"password": "<password>", "roles": ["squirro_conversations"]}. Without the role in the body, the user has no access.

Changing the Password of GenAI’s User#

Neither the start script nor search-users-init changes the password of an existing user. To give GenAI’s user a new password, delete the user and let the next start create it again. Conversation searches answer 503 from the deletion until the next start completes.

  1. Delete the user on the search engine as the administrator. On OpenSearch, send a DELETE to _plugins/_security/api/internalusers/squirro_conversations. On Elasticsearch, run DELETE _security/user/squirro_conversations. The role stays.

  2. Replace the password and restart GenAI:

    • RPM installations. On one node, delete /etc/squirro/genai.d/squirro_conversations.password and restart GenAI. The start generates a new password and creates the user with it. Then copy the file to every other node that runs GenAI, keep the sqgenai owner and the mode 600, and restart GenAI there.

    • Docker Compose. Delete secrets/search_engine_genai_password.sec, run ./ensure_secrets.sh to generate a new one, and recreate both containers that read it with docker compose up -d --force-recreate genai search-users-init.

On a managed cluster, on which the administrator cannot manage users, skip step 1. After step 2, set the password of the user by hand to the content of the new file, as described under Creating the Role and the User.

Rolling Back and Removing the Copy#

GenAI does not remove the search copies on its own when you turn search off or downgrade the release. To remove them, delete the conversation indices from the search engine. Each project has an alias named <prefix>_conversation_search_index_<project>, and the index behind it is named <alias>.v<N>. Elasticsearch refuses to delete indices by a wildcard, so list them with GET _cat/indices/<prefix>_conversation_search_index_* and delete each one by its name.

  • Downgrade, or a database restore taken before the upgrade. Delete the conversation indices. The earlier release does not maintain them, and they no longer match the database. The next upgrade copies the conversations again. If the earlier release also has conversation search, also delete the rows of the v1_search_projects table in the GenAI database and restart GenAI. Otherwise, that release skips each project whose index a later release built, and searches in those projects answer 503.

  • Deleted projects. When you delete a project, its index stays in the search engine and keeps the text of that project’s conversations. To remove it, delete the indices whose names start with <prefix>_conversation_search_index_<project ID in lowercase>.v.