[null,null,["最終更新日 2025-08-29 UTC。"],[],[],null,["# Implement autocomplete\n\nCloud Search's autocomplete assists a user by suggesting words\nwhen the user is typing a search query. For example, suggestions might be words\nfrom document titles, search operators, search operator values, or names and\nemail addresses from the Google Workspace organization.\n\nAutocomplete extracts phrases from the titles of indexed documents and, using an\n[n-gram model](https://en.wikipedia.org/wiki/N-gram),\ndetermines suggestions to serve using the Suggest API. By default, phrases from\nthe document titles are shown in autocomplete. You can also mark text and enum\nschema properties as `is_suggestable` to autocomplete the corresponding property\nname and values.\n\nThe Suggest API examines the search query for hints about the query's language,\nsuch as English or Spanish, and prioritizes results accordingly. The\n[`languageCode`](/workspace/cloud-search/docs/reference/rest/v1/RequestOptions) field\nof a request is also used to improve language-specific suggestions.\n\nExample scenario\n----------------\n\nFor example, let's say you have the following datasource containing data about\nmovies:\n\n- The datasource contains 2 documents.\n- Each document has a title (`ItemMetadata.title`) and two properties: `genre` and `characters`.\n- The first document is titled \"Avengers Infinity War\" with `genre=science fiction` and `characters=Iron Man, Hulk`\n- The second document is titled \"Harry Potter\" with `genre=Adventure, Fantasy\n and`characters=Hermione, Harry Potter\\`\n\nFigure 1 illustrates how the autocomplete suggestions are extracted from the\ndocument titles, properties, and the property values.\n**Figure 1.** Two documents and resulting n-gram used for autocomplete\n\nFrom document 1, we extract ngrams (up to trigrams) \"Avengers\", \"Infinity\", \"War\",\n\"Avengers Infinity\", \"Infinity War\", \"Avengers Infinity War.\"\nSimilarly from document 2, we generate \"Harry\", \"Potter\", \"Harry Potter\".\n\nWhen querying this datasource, let's say the user starts by typing \"h.\" The\nsuggestions shown to the user would be:\n\n- Harry\n- Hermione\n- Hulk\n- Harry Potter\n\nLet's say the user selects the autocomplete suggestion \"Hermione\" and the next\nkeystroke from the user is the character \"a.\" The autocomplete suggestions shown\nto the user would be:\n\n- Hermione Adventure\n- Hermione Action\n- Hermione Avengers\n\nAutocomplete tries to complete the last word (or ngram) being typed.\nIn the previous example, it just expands \"a\" to \"adventure\", \"action\" and\n\"avengers\" since there is no text starting with \"hermione a\" together. This\nsuggestion is called tail suggestion; autocompleting only the last word/n-gram\nbeing typed.\n\nCloud Search's autocomplete returns a maximum of 5 suggestions\nfrom document content and 2 people suggestions.\n| **Important:** Cloud Search's autocomplete suggests phrases only from those documents a user has access to.\n\nBy default, phrases from the document titles are shown in autocomplete. Schema\nproperties must be explicitly marked as `is_suggestable` for the suggest API to\nautocomplete the corresponding property name and values.\n| **Note:** `is_suggestable` is supported only for text and enum properties.\n\nIntegrate with the Autocomplete API\n-----------------------------------\n\nIf you are using the default search application or the embeddable search\nwidget, Cloud Search's autocomplete feature is natively supported\nwithout any additional work. Remember, by default, phrases from the document\ntitles are shown in autocomplete. Schema properties must be explicitly marked as\n`is_suggestable` for the suggest API to autocomplete the corresponding property\nname and values.\n\nIf you are building a custom search application, autocomplete\nis available by querying the `/query/suggest` API endpoints.\n| **Note:** After documents are indexed, it takes at least 48 hours before autocomplete results appear. Additionally, reindexing causes a delay in the use of autocomplete for that property.\n\nLimitations\n-----------\n\nAutocomplete has the following limitations:\n\n- Restricting Cloud Search's autocomplete phrases using the\n [`FilterOptions`](/workspace/cloud-search/docs/reference/rest/v1/settings.searchapplications#FilterOptions)\n defined in the schema is not supported except for the following built-in\n filters: `objectype`, `mimetype`, and type filters.\n\n- Query history-based suggestions (searches performed by the user previously in\n a search application) are not supported\n\n- A maximum of 20 properties can be marked as `is_suggestable`. This limit can\n be increased by contacting Cloud Search support.\n\n- Search operator autocomplete is not available for properties with\n `exact_match_with_operator`.\n\n- Cloud Search's autocomplete returns a maximum of 5 suggestions\n from document content and 2 people suggestions.\n\n- Cloud Search's autocomplete suggests phrases only from those\n documents a user has access to."]]