Skip to main content
Last updated: 9 Jan 2025

search-api-v2: Search autocomplete

We use Vertex AI Search's built-in autocomplete functionality to provide our users with helpful suggestions to complete their query as they type in search fields.

Search API v2 provides an API to return suggestions, which the search_with_autocomplete component in frontend rendering apps accesses through a proxy endpoint on Finder Frontend. Other internal clients and the GOV.UK app may access it directly or through an API gateway.

Update denylist

We use a denylist to avoid the autocomplete returning suggestions that are not suitable or helpful.

Updating this list currently requires a manual process until we complete the work to automate it:

  1. In a text editor create a new empty file, save this file as denylist.jsonl (JSON Lines format)
  2. Access the denylist spreadsheet and apply the desired changes to the appropriate tab
  3. Copy and paste the contents from the "denylist" column from each of the several tabs into your created denylist.jsonl file

Then for each GOV.UK environment of integration, staging and production:

  1. Log into Google Cloud and access the Search API V2 <environment> project
  2. Access "Cloud Storage" > "Buckets" and find the search-api-v2-<environment>_vais_artifacts bucket
  3. Upload the denylist.jsonl file to the bucket, replacing the existing file
  4. Leave Google Cloud and open your terminal
  5. Log into the appropriate environment for Kubernetes
  6. Run the rake autocomplete:update_denylist rake task for search-api-v2 to import the file

If there are problems updating the denylist we can consider disabling the autocomplete feature temporarily to provide time to resolve the problem.

Disable search autocomplete

If poor suggestions are shown to users that cannot be mitigated through the denylist, or there is a problem updating the denylist, or autocomplete needs to be turned off for another reason, the ENABLE_AUTOCOMPLETE feature flag environment variable for Search API v2 can be turned off.

This will cause an empty array of suggestions to be returned to all clients (web or otherwise).

  1. Open the appropriate values-<environment>.yaml file from GOV.UK Helm Charts, for example values-production.yaml
  2. Set ENABLE_AUTOCOMPLETE in extraEnv to false
  3. Open a PR to apply the change
  4. Once merged, a new deployment will be created for Search API v2 and no suggestions will be returned