This page describes Agentspace Enterprise's basic autocomplete feature. Autocomplete generates query suggestions based on the first few characters entered for the query.
For structured and unstructured data, by default, autocomplete generates suggestions based on the content of documents in the data store. After document import, by default, autocomplete doesn't start generating suggestions until there is sufficient quality data, typically a couple of days. If you make autocomplete requests through the API, autocomplete can generate suggestions that are based on the search history or user events.
The autocomplete data model determines what type of data autocomplete uses to generate suggestions. There are four autocomplete models:
Document. The document model generates suggestions from user-imported documents.
Completable Fields. The completable fields model suggests text taken directly from structured data fields. Only those fields that are annotated with
completable
are used for autocomplete suggestions. This model is only available for structured data.Search history. The search history model generates suggestions from the history of
SearchService.search
API calls. Don't use this model if there is no traffic available for theservingConfigs.search
method.User event. The user event model generates suggestions from user-imported search events.
Autocomplete requests are sent using the
dataStores.completeQuery
method.
The following table shows the autocomplete model types available for each data type.
Autocomplete data model |
Data source |
Website data |
Structured data |
Unstructured data |
---|---|---|---|---|
Document | Imported by user | ✔* (default) | ✔ (default) | |
Completable fields | Imported by user | ✔ | ||
Search history | Automatically collected | ✔ (default) | ✔ | ✔ |
User events | Imported by user or automatically collected by widget | ✔ | ✔ | ✔ |
* : The document schema must contain title
or description
fields, or there
must be fields that have been specified as title
or description
key
properties. See
Update a schema for structured data.
If you don't want to use the default model for your data type, you can
specify a different model when you send your autocomplete request. Autocomplete
requests are sent using the dataStores.completeQuery
method. For
information, see API instructions: Send an autocomplete request to choose a
different model.
Autocomplete features
Agentspace Enterprise supports the following autocomplete features to show the most helpful predictions when searching:
Feature | Description | Example or more information |
---|---|---|
Correct typos | Correct word spellings that are typos. | Milc → Milk .
|
Remove unsafe terms |
|
Text that's offensive, such as porn, racy, vulgar, violence. |
Denylist |
|
For more information, see Use an autocomplete denylist. |
Deduplicate Terms |
|
Shoes for Women , Womens Shoes , and Womans Shoes are deduplicated,
and only the most popular one is suggested. |
Tail match suggestions |
|
For more information, see Tail match suggestions. |
Tail match suggestions
Tail match suggestions are made using exact prefix matching against the last word in a query string.
For example, say the query "songs with he" is sent in an autocomplete request. When tail matching is enabled, autocomplete might find that the full prefix "songs with he" does not have any matches. However, the last word in the query, "he", has an exact prefix match with "hello world" and "hello kitty". In that case, the returned suggestions are "songs with hello world" and "songs with hello kitty" because there are no full match suggestions.
You can use this feature to reduce empty suggestion results and increase suggestion diversity, making this especially useful in cases where data sources (user event count, search history, and document topic coverage) is limited. However, enabling tail match suggestions can reduce the overall quality of suggestions. Because tail match only matches the trailing word of the prefix, some returned suggestions might not make sense. For example, a query such as "songs with he" might get a tail match suggestion like "songs with helpers guides".
Tail match suggestions are only returned if:
include_tail_suggestions
is set totrue
in thedataStores.completeQuery
request.There are no full prefix match suggestions for the query.
Turn autocomplete on or off for a widget
To turn autocomplete on or off for a widget, follow these steps:
Console
In the Google Cloud console, go to the Agentspace page.
Click the name of the app that you want to edit.
Click Configurations.
Click the UI tab.
Toggle the Show autocomplete suggestions option to turn autocomplete suggestions for the widget on or off. When you enable autocomplete, expect to wait a day or two before suggestions start.
Update autocomplete settings
To configure the autocomplete settings, follow these steps:
Console
In the Google Cloud console, go to the Agentspace page.
Click the name of the app that you want to edit.
Click Configurations.
Click the Autocomplete tab.
Enter or select new values for the autocomplete settings you want to update:
- Maximum number of suggestions: The maximum number of autocomplete suggestions that can be offered for a query.
- Minimum length to trigger: The minimum number of characters that can be typed before autocomplete suggestions are offered.
- Matching order: The location in a query string that autocomplete can start matching its suggestions from.
- Autocomplete model: The autocomplete data model used to generate
the retrieved suggestions. This can be overridden in the
dataStores.completeQuery
using thequeryModel
parameter. Enable autocomplete: By default, autocomplete doesn't start making suggestions until it has sufficient quality data, typically a couple of days. If you want to override this default and start getting some autocomplete suggestions sooner, select Now.
Even when you select Now, it can take a day for suggestions to be generated and still some autocomplete suggestions will be missing or poor quality until there is sufficient good data.
Click Save and publish. Changes take effect within a few minutes for engines where autocomplete has already been turned on.
Update completable field annotations in schema
To turn on autocomplete for fields in structured data schema, follow these steps:
Console
In the Google Cloud console, go to the Agentspace page.
Click the name of the app that you want to edit. It must use structured data.
Click Data.
Click the Schema tab.
Click Edit to select the schema fields to mark as
completable
.Click Save to save the updated field configurations. These suggestions take around a day to be generated and returned.
Send autocomplete requests
The following samples show how to send autocomplete requests.
To send an autocomplete request using the API, follow these steps: Find your data store ID. If you already have your data store
ID, skip to the next step. In the Google Cloud console, go to the Agentspace page and
in the navigation menu, click Data Stores. Click the name of your data store. On the Data page for your data store, get the data store ID. Call the
PROJECT_ID: The project number or ID of your
Google Cloud project. DATA_STORE_ID: The ID of the data store that is associated
with your app. QUERY_STRING: The typeahead input used to
fetch suggestions. To send an autocomplete request with a different autocomplete data model, follow
these steps: Find your data store ID. If you already have your data store
ID, skip to the next step. In the Google Cloud console, go to the Agentspace page and
in the navigation menu, click Data Stores. Click the name of your data store. On the Data page for your data store, get the data store ID. Call the
Before trying this sample, follow the C# setup instructions in the
Agentspace Enterprise quickstart using
client libraries.
For more information, see the
Agentspace Enterprise C# API
reference documentation.
To authenticate to Agentspace Enterprise, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Before trying this sample, follow the Go setup instructions in the
Agentspace Enterprise quickstart using
client libraries.
For more information, see the
Agentspace Enterprise Go API
reference documentation.
To authenticate to Agentspace Enterprise, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Before trying this sample, follow the Java setup instructions in the
Agentspace Enterprise quickstart using
client libraries.
For more information, see the
Agentspace Enterprise Java API
reference documentation.
To authenticate to Agentspace Enterprise, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Before trying this sample, follow the Node.js setup instructions in the
Agentspace Enterprise quickstart using
client libraries.
For more information, see the
Agentspace Enterprise Node.js API
reference documentation.
To authenticate to Agentspace Enterprise, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Before trying this sample, follow the Python setup instructions in the
Agentspace Enterprise quickstart using
client libraries.
For more information, see the
Agentspace Enterprise Python API
reference documentation.
To authenticate to Agentspace Enterprise, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Before trying this sample, follow the Ruby setup instructions in the
Agentspace Enterprise quickstart using
client libraries.
For more information, see the
Agentspace Enterprise Ruby API
reference documentation.
To authenticate to Agentspace Enterprise, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
REST
dataStores.completeQuery
method.curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID:completeQuery?query=QUERY_STRING"
Send an autocomplete request to a different model
dataStores.completeQuery
method.curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID:completeQuery?query=QUERY_STRING&query_model=AUTOCOMPLETE_MODEL"
document
, document-completable
,
search-history
, or user-event
.C#
Go
Java
Node.js
Python
Ruby
Use an autocomplete denylist
You can use a denylist to prevent specific terms from appearing as autocomplete suggestions.
For example, take a pharmaceutical company. If a medication is no longer FDA-approved but is mentioned in documents in their data store, they might want to prevent that medication from appearing as a suggested query. The company could add the name of that medication to a denylist to prevent it from being suggested.
The following limits apply:
- One denylist per data store
- Uploading a denylist overwrites any existing denylist for that data store
- Up to 1000 terms per denylist
- Terms are case-insensitive
- After importing a denylist, it takes 1-2 days to take effect
Each entry of your denylist consists of a blockPhrase
and matchOperator
:
blockPhrase
: Enter a string as your denylist term. Terms are case-insensitive.matchOperator
: Accepts the following values:EXACT_MATCH
: Prevents an exact match of the denylist term from appearing as a suggested query.CONTAINS
: Prevents any suggestion that contains the denylist term from appearing.
The following is an example of a denylist with four entries:
{ "entries": [ {"blockPhrase":"Oranges","matchOperator":"CONTAINS"}, {"blockPhrase":"bAd apples","matchOperator":"EXACT_MATCH"}, {"blockPhrase":"Cool as A Cucumber","matchOperator":"EXACT_MATCH"}, {"blockPhrase":"cherry pick","matchOperator":"CONTAINS"} ] }
Prior to importing a denylist, verify that the necessary access controls are set for Discovery Engine editor access.
Denylists can be imported either from local JSON data or from Cloud Storage. To remove a denylist from a data store, purge the denylist.
Import a denylist from local JSON data
To import a denylist from a local JSON file containing your denylist, do the following:
Create your denylist in a local JSON file with the following format. Make sure each denylist entry is in a new line with no line breaks.
{ "inlineSource": { "entries": [ { "blockPhrase":"TERM_1","matchOperator":"MATCH_OPERATOR_1" }, { "blockPhrase":"TERM_2","matchOperator":"MATCH_OPERATOR_2" } ] } }
Make a POST request to the
suggestionDenyListEntries:import
method, providing the name of your JSON file.curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data @DENYLIST_FILE \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/dataStores/DATA_STORE_ID/suggestionDenyListEntries:import"
- DENYLIST_FILE: The local path of the JSON file containing the denylist terms.
- PROJECT_ID: The project number or ID of your Google Cloud project.
- DATA_STORE_ID: The ID of the data store that is associated with your app.
After importing your denylist, it takes 1-2 days to start filtering suggestions.
Import a denylist from Cloud Storage
To import a denylist from a JSON file in Cloud Storage, do the following:
Create your denylist in a JSON file with the following format and import to a Cloud Storage bucket. Make sure each denylist entry is in a new line with no line breaks.
{ "blockPhrase":"TERM_1","matchOperator":"MATCH_OPERATOR_1" } { "blockPhrase":"TERM_2","matchOperator":"MATCH_OPERATOR_2" }
Create a local JSON file containing the
gcsSource
object. Use this to point to your denylist file's location in a Cloud Storage bucket.{ "gcsSource": { "inputUris": [ "DENYLIST_STORAGE_LOCATION" ] } }
- DENYLIST_STORAGE_LOCATION: The location of your denylist in
Cloud Storage. You can enter only one URI. The URI must be entered in
this format:
gs://BUCKET/FILE_PATH
.
- DENYLIST_STORAGE_LOCATION: The location of your denylist in
Cloud Storage. You can enter only one URI. The URI must be entered in
this format:
Make a POST request to the
suggestionDenyListEntries:import
method, including thegcsSource
object.curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data @GCS_SOURCE_FILE \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/dataStores/DATA_STORE_ID/suggestionDenyListEntries:import"
- GCS_SOURCE_FILE: The local path of the file containing
the
gcsSource
object that points to your denylist. - PROJECT_ID: The project number or ID of your Google Cloud project.
- DATA_STORE_ID: The ID of the data store that is associated with your app.
- GCS_SOURCE_FILE: The local path of the file containing
the
After importing your denylist, it takes 1-2 days to start filtering suggestions.
Purge a denylist
To purge a denylist from your data store, do the following:
Make a POST request to the
suggestionDenyListEntries:purge
method.curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/dataStores/DATA_STORE_ID/suggestionDenyListEntries:purge"
- PROJECT_ID: The project number or ID of your Google Cloud project.
- DATA_STORE_ID: The ID of the data store that is associated with your app.
Advanced document data model
Google Agentspace Enterprise provides an advanced data model for autocomplete. Based on the documents you import, this data model generates high-quality autocomplete suggestions by leveraging Google large language models (LLMs).
This feature is experimental. If you're interested in using this feature, contact your Google Cloud account team and ask to be added to the allowlist.