Cloud Search’s autocomplete assists a user by suggesting words when the user is typing a search query. The suggestions might be words from document titles, search operators, search operator values, names and email from the G Suite domain, and so on.
Autocomplete extracts the phrases from the titles of indexed documents and, using an n-gram model, determines suggestions to serve using the Suggest API. For example, let's say we have the following datasource containing data about movies:
- The datasource contains 2 documents.
- Each document has a title (
ItemMetadata.title) and two properties:
- The first document is titled "Avengers Infinity War” with
characters=Iron Man, Hulk
- The second document is titled "Harry Potter" with
genre=Adventure, Fantasy andcharacters=Hermione, Harry Potter`
Figure 1 illustrates how the autocomplete suggestions are extracted from the document titles, properties, and the property values.
From document 1, we extract ngrams (up to trigrams) “Avengers”, “Infinity”, “War”, “Avengers Infinity”, “Infinity War”, “Avengers Infinity War.” Similarly from document 2, we generate “Harry”, “Potter”, “Harry Potter”.
When querying this datasource, let's say the user starts by typing "h." The suggestions shown to the user would be:
- Harry Potter
Let's say the user selects the autocomplete suggestion “Hermione” and the next keystroke from the user is the character "a." The autocomplete suggestions shown to the user would be:
- Hermione Adventure
- Hermione Action
- Hermione Avengers
Cloud Search’s autocomplete returns a maximum of 5 suggestions from document content and 2 people suggestions.
By default, phrases from the document titles are shown in autocomplete. Schema
properties must be explicitly marked as
is_suggestable for the suggest API to
autocomplete the corresponding property name and values.
Integrate with the Autocomplete API
If you are using the default search application or the embeddable search
widget, Cloud Search’s autocomplete feature is natively supported without any
additional work. Remember, by default, phrases from the document titles are shown
in autocomplete. Schema properties must be explicitly marked as
for the suggest API to autocomplete the corresponding property name and values.
If you are building a custom search application, autocomplete
is available by querying the
/query/suggest API endpoints.
Autocomplete has the following limitations:
Restricting Cloud Search’s autocomplete phrases using the
FilterOptionsdefined in the schema is not supported except for the following built-in filters:
mimetype, and type filters.
Query history-based suggestions (searches performed by the user previously in a search application) are not supported
A maximum of 20 properties can be marked as
is_suggestable. This limit can be increased by contacting Cloud Search support.
Search operator autocomplete is not available for properties with