![]() ![]() This will allow one of the fields to have a suggester, while the other can be set up with a custom analyzer configuration. If you need to work around the analyzer constraint, for example if you need a keyword or ngram analyzer for certain query scenarios, you should use two separate fields for the same content. Once you build an index, you can try various analyzers on a string to view token output.įields that use custom analyzers or built-in analyzers (with the exception of standard Lucene) are explicitly disallowed to prevent poor outcomes. When evaluating analyzers, consider using the Analyze Text API for insight into how terms are processed. Had you used the standard Lucene analyzer, the hyphenated string wouldn't exist. For example, for a hyphenated string like "context-sensitive", using a language analyzer will result in these token combinations: "context", "sensitive", "context-sensitive". ![]() Your choice of an analyzer determines how fields are tokenized and subsequently prefixed. To satisfy both search-as-you-type experiences, add all of the fields that you need for autocomplete, but then use "$select", "$top", "$filter", and "searchFields" to control results for suggestions. If fields consist of repetitive values, the suggestions consist of identical results and a user won't know which one to click. Names, titles, or other unique fields that distinguish among multiple matches work best. Remember that the suggestion is a proxy for a search document so you'll want fields that best represent a single result. Suggestions, on the other hand, produce better results when your field choice is selective. There's one suggester for each index, so the suggester list must include all fields that contribute content for both suggestions and autocomplete.Īutocomplete benefits from a larger pool of fields to draw from because the additional content has more term completion potential. Choose fieldsĪlthough a suggester has several properties, it's primarily a collection of string fields for which you're enabling a search-as-you-type experience. For more information, see How to rebuild an Azure Cognitive Search index. Given that existing fields are already tokenized, you'll have to rebuild the index if you want to add them to a suggester. Prefixes are generated during indexing, when partial terms in two or more character combinations are tokenized alongside whole terms. If you try to create a suggester using pre-existing fields, the API will disallow it. Use the default standard Lucene analyzer ( "analyzer": null) or a language analyzer (for example, "analyzer": "en.Microsoft") on the field. If the string field is part of a complex type (for example, a City field within Address), include the parent in the field path: "Address/City" (REST and C# and Python), or (JavaScript). The best time to create a suggester is when you're also defining the field that will use it. A suggester takes a name and a collection of fields over which the typeahead experience is enabled. To create a suggester, add one to an index definition. Both requests target the documents collection of specific index and responses are returned after a user has provided at least a three character input string. You can implement both typeahead behaviors within the same search solution if you want an experience similar to the one indicated in the screenshot. Search-as-you-type support is enabled on a per-field basis for string fields. The remainder of this article is focused on creating a suggester.Ĭall a suggester-enabled query, in the form of a Suggestion request or Autocomplete request, using one of the APIs listed below. To implement these behaviors in Azure Cognitive Search, there's an index and query component.Īdd a suggester to a search index definition. You can use these features separately or together. For suggestions, you can surface any field that provides descriptive information. Suggestions are mini search results, where a field like hotel name represents a matching hotel search document from the index. Autocomplete anticipates a potential term, finishing "tw" with "in". The following screenshot from Create your first app in C# illustrates both. Typeahead can be autocomplete, which completes a partial input for a whole term query, or suggestions that invite click through to a particular match. Typeahead experiences in Cognitive Search The same suggester supports both experiences. ![]() Matches on partial terms can be either an autocompleted query or a suggested match. For example, a suggester that includes a City field with a value for "Seattle" will have prefix combinations of "sea", "seat", "seatt", and "seattl" to support typeahead. ![]() A suggester provides a list of fields that undergo extra tokenization, generating prefix sequences to support matches on partial terms. In Azure Cognitive Search, typeahead or "search-as-you-type" is enabled through a suggester. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |