Skip to content

Commit 838d6c1

Browse files
Merge pull request #940 from cdpark/refresh-oct-heidist2
Feature 322546: Q&M: Freshness - AI Services & Search 180d target - Oct sprint - heidist2
2 parents e976d1c + e294082 commit 838d6c1

File tree

3 files changed

+63
-63
lines changed

3 files changed

+63
-63
lines changed

articles/search/index-add-suggesters.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Configure a suggester
2+
title: Configure a suggester for autocomplete and suggestions
33
titleSuffix: Azure AI Search
44
description: Enable typeahead query actions in Azure AI Search by creating suggesters and formulating requests that invoke autocomplete or autosuggested query terms.
55

@@ -8,46 +8,46 @@ author: HeidiSteen
88
ms.author: heidist
99
ms.service: azure-ai-search
1010
ms.topic: conceptual
11-
ms.date: 01/18/2024
11+
ms.date: 10/21/2024
1212
ms.custom:
1313
- devx-track-csharp
1414
- devx-track-dotnet
1515
- ignite-2023
1616
---
1717

18-
# Configure a suggester for autocomplete and suggested matches in a query
18+
# Configure a suggester for autocomplete and suggestions in a query
1919

20-
In Azure AI Search, typeahead (autocomplete) or "search-as-you-type" is enabled through a *suggester*. A suggester is a configuration in an index specifying which fields should be used to populate autocomplete and suggestions. These fields undergo extra tokenization, generating prefix sequences to support matches on partial terms. 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.
20+
In Azure AI Search, typeahead or "search-as-you-type" is enabled by using a *suggester*. A suggester is a configuration in an index that specifies which fields should be used to populate autocomplete and suggested matches. These fields undergo extra tokenization, generating prefix sequences to support matches on partial terms. For example, a suggester that includes a `city` field with a value for *Seattle* has prefix combinations of *sea*, *seat*, *seatt*, and *seattl* to support typeahead.
2121

2222
Matches on partial terms can be either an autocompleted query or a suggested match. The same suggester supports both experiences.
2323

2424
## Typeahead experiences in Azure AI Search
2525

26-
Typeahead can be *autocomplete*, which completes a partial input for a whole term query, or *suggestions* that invite click through to a particular match. Autocomplete produces a query. Suggestions produce a matching document.
26+
Typeahead can use *autocomplete*, which completes a partial input for a whole term query, or *suggestions* that invite click through to a particular match. Autocomplete produces a query. Suggestions produce a matching document.
2727

28-
The following screenshot illustrates both. Autocomplete anticipates a potential term, finishing "tw" with "in". Suggestions are mini search results, where a field like hotel name represents a matching hotel search document from the index. For suggestions, you can surface any field that provides descriptive information.
28+
The following screenshot illustrates both. Autocomplete anticipates a potential term, finishing *tw* with *in*. Suggestions are mini search results, where a field like `hotel name` represents a matching hotel search document from the index. For suggestions, you can surface any field that provides descriptive information.
2929

30-
![Visual comparison of autocomplete and suggested queries](./media/index-add-suggesters/hotel-app-suggestions-autocomplete.png "Visual comparison of autocomplete and suggested queries")
30+
:::image type="content" source="media/index-add-suggesters/hotel-app-suggestions-autocomplete.png" alt-text="Screenshot showing visual comparison of autocomplete and suggested queries.":::
3131

3232
You can use these features separately or together. To implement these behaviors in Azure AI Search, there's an index and query component.
3333

34-
+ Add a suggester to a search index definition. The remainder of this article is focused on creating a suggester.
34+
+ Add a suggester to a search index definition. The remainder of this article focuses on creating a suggester.
3535

36-
+ Call a suggester-enabled query, in the form of a Suggestion request or Autocomplete request, using one of the [APIs listed in a later section](#how-to-use-a-suggester).
36+
+ Call a suggester-enabled query, in the form of a suggestion request or autocomplete request, by using one of the APIs listed in [Use a suggester](#how-to-use-a-suggester).
3737

38-
Search-as-you-type is enabled on a per-field basis for string fields. You can implement both typeahead behaviors within the same search solution if you want an experience similar to the one indicated in the screenshot. Both requests target the *documents* collection of specific index and responses are returned after a user provides at least a three character input string.
38+
Search-as-you-type is enabled on a per-field basis for string fields. You can implement both typeahead behaviors within the same search solution if you want an experience similar to the one indicated in the screenshot. Both requests target the *documents* collection of a specific index, and responses are returned after a user provides at least a three-character input string.
3939

4040
## How to create a suggester
4141

4242
To create a suggester, add one to an [index definition](/rest/api/searchservice/indexes/create). A suggester takes a name and a collection of fields over which the typeahead experience is enabled. The best time to create a suggester is when you're also defining the field that uses it.
4343

4444
+ Use string fields only.
4545

46-
+ 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 `["Address"]["City"]` (JavaScript).
46+
+ 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, C#, and Python), or `["Address"]["City"]` (JavaScript).
4747

4848
+ Use the default standard Lucene analyzer (`"analyzer": null`) or a [language analyzer](index-add-language-analyzers.md) (for example, `"analyzer": "en.Microsoft"`) on the field.
4949

50-
If you try to create a suggester using pre-existing fields, the API disallows it. Prefixes are generated during indexing, when partial terms in two or more character combinations are tokenized alongside whole terms. Given that existing fields are already tokenized, you have to rebuild the index if you want to add them to a suggester. For more information, see [How to rebuild an Azure AI Search index](search-howto-reindex.md).
50+
If you try to create a suggester using preexisting fields, the API disallows it. Prefixes are generated during indexing, when partial terms in two or more character combinations are tokenized alongside whole terms. Given that existing fields are already tokenized, you have to rebuild the index if you want to add them to a suggester. For more information, see [Update or rebuild an index in Azure AI Search](search-howto-reindex.md).
5151

5252
### Choose fields
5353

@@ -61,28 +61,28 @@ To satisfy both search-as-you-type experiences, add all of the fields that you n
6161

6262
### Choose analyzers
6363

64-
Your choice of an analyzer determines how fields are tokenized and prefixed. For example, for a hyphenated string like "context-sensitive", using a language analyzer results in these token combinations: "context", "sensitive", "context-sensitive". Had you used the standard Lucene analyzer, the hyphenated string wouldn't exist.
64+
Your choice of an analyzer determines how fields are tokenized and prefixed. For example, for a hyphenated string like *context-sensitive*, using a language analyzer results in these token combinations: *context*, *sensitive*, *context-sensitive*. Had you used the standard Lucene analyzer, the hyphenated string wouldn't exist.
6565

6666
When evaluating analyzers, consider using the [Analyze Text API](/rest/api/searchservice/indexes/analyze) for insight into how terms are processed. Once you build an index, you can try various analyzers on a string to view token output.
6767

68-
Fields that use [custom analyzers](index-add-custom-analyzers.md) or [built-in analyzers](index-add-custom-analyzers.md#built-in-analyzers) (except for standard Lucene) are explicitly disallowed to prevent poor outcomes.
68+
Fields that use [custom analyzers](index-add-custom-analyzers.md) or [built-in analyzers](index-add-custom-analyzers.md#built-in-analyzers), (except for standard Lucene) are explicitly disallowed to prevent poor outcomes.
6969

7070
> [!NOTE]
71-
> 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. This will allow one of the fields to have a suggester, while the other can be set up with a custom analyzer configuration.
71+
> 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. This allows one of the fields to have a suggester, while the other can be set up with a custom analyzer configuration.
7272
73-
## Create using the portal
73+
## Create using the Azure portal
7474

7575
When using **Add Index** or the **Import data** wizard to create an index, you have the option of enabling a suggester:
7676

7777
1. In the index definition, enter a name for the suggester.
7878

79-
1. In each field definition for new fields, select a checkbox in the Suggester column. A checkbox is available on string fields only.
79+
1. In each field definition for new fields, select a checkbox in the **Suggester** column. A checkbox is available on string fields only.
8080

8181
As previously noted, analyzer choice impacts tokenization and prefixing. Consider the entire field definition when enabling suggesters.
8282

8383
## Create using REST
8484

85-
In the REST API, add suggesters through [Create Index](/rest/api/searchservice/indexes/create) or [Update Index](/rest/api/searchservice/indexes/create-or-update).
85+
In the REST API, add suggesters by using [Create Index](/rest/api/searchservice/indexes/create) or [Update Index](/rest/api/searchservice/indexes/create-or-update).
8686

8787
```json
8888
{
@@ -142,7 +142,7 @@ private static void CreateIndex(string indexName, SearchIndexClient indexClient)
142142
|Property |Description |
143143
|--------------|-----------------|
144144
| name | Specified in the suggester definition, but also called on an Autocomplete or Suggestions request. |
145-
| sourceFields | Specified in the suggester definition. It's a list of one or more fields in the index that are the source of the content for suggestions. Fields must be of type `Edm.String`. If an analyzer is specified on the field, it must be a named lexical analyzer from [this list](/dotnet/api/azure.search.documents.indexes.models.lexicalanalyzername) (not a custom analyzer). </br></br>As a best practice, specify only those fields that lend themselves to an expected and appropriate response, whether it's a completed string in a search bar or a dropdown list. </br></br>A hotel name is a good candidate because it has precision. Verbose fields like descriptions and comments are too dense. Similarly, repetitive fields, such as categories and tags, are less effective. In the examples, we include "category" anyway to demonstrate that you can include multiple fields. |
145+
| sourceFields | Specified in the suggester definition. It's a list of one or more fields in the index that are the source of the content for suggestions. Fields must be of type `Edm.String`. If an analyzer is specified on the field, it must be a named lexical analyzer listed on [LexicalAnalyzerName Struct](/dotnet/api/azure.search.documents.indexes.models.lexicalanalyzername) (not a custom analyzer). </br></br>As a best practice, specify only those fields that lend themselves to an expected and appropriate response, whether it's a completed string in a search bar or a dropdown list. </br></br>A hotel name is a good candidate because it has precision. Verbose fields like descriptions and comments are too dense. Similarly, repetitive fields, such as categories and tags, are less effective. In the examples, we include *category* anyway to demonstrate that you can include multiple fields. |
146146
| searchMode | REST-only parameter, but also visible in the portal. This parameter isn't available in the .NET SDK. It indicates the strategy used to search for candidate phrases. The only mode currently supported is `analyzingInfixMatching`, which currently matches on the beginning of a term.|
147147

148148
<a name="how-to-use-a-suggester"></a>
@@ -151,7 +151,7 @@ private static void CreateIndex(string indexName, SearchIndexClient indexClient)
151151

152152
A suggester is used in a query. After a suggester is created, call one of the following APIs for a search-as-you-type experience:
153153

154-
+ [Suggestions REST API](/rest/api/searchservice/documents/suggest-post)
154+
+ [Suggest REST API](/rest/api/searchservice/documents/suggest-post)
155155
+ [Autocomplete REST API](/rest/api/searchservice/documents/autocomplete-post)
156156
+ [SuggestAsync method](/dotnet/api/azure.search.documents.searchclient.suggestasync)
157157
+ [AutocompleteAsync method](/dotnet/api/azure.search.documents.searchclient.autocompleteasync)
@@ -170,11 +170,11 @@ POST /indexes/myxboxgames/docs/autocomplete?search&api-version=2024-07-01
170170

171171
## Sample code
172172

173-
+ [Add search to a web site (C#)](tutorial-csharp-search-query-integration.md) uses an open source Suggestions package for partial term completion in the client app.
173+
To learn how to use an open source Suggestions package for partial term completion in the client app, see [Explore the .NET search code](tutorial-csharp-search-query-integration.md).
174174

175-
## Next steps
175+
## Next step
176176

177-
Learn more about requests\ formulation.
177+
Learn more about request formulation.
178178

179179
> [!div class="nextstepaction"]
180-
> [Add autocomplete and suggestions to client code](search-add-autocomplete-suggestions.md)
180+
> [Add autocomplete and search suggestions in client apps](search-add-autocomplete-suggestions.md)

0 commit comments

Comments
 (0)