SearchClient.SuggestAsync<T> Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Executes a "search-as-you-type" query consisting of a partial text input (three character minimum). It returns matching text found in suggester-aware fields. Azure Cognitive Search looks for matching values in fields that are predefined in a Suggester. For example, if you enable suggestions on a city field, typing "sea" produces documents containing "Seattle", "Sea Tac", and "Seaside" (all actual city names) for that field. Suggestions

C#
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Models.SuggestResults<T>>> SuggestAsync<T>(string searchText, string suggesterName, Azure.Search.Documents.SuggestOptions options = default, System.Threading.CancellationToken cancellationToken = default);

Type Parameters

T

The .NET type that maps to the index schema. Instances of this type can be retrieved as documents from the index.

Parameters

searchText
String

The search text to use to suggest documents. Must be at least 1 character, and no more than 100 characters.

suggesterName
String

The name of the suggester as specified in the suggesters collection that's part of the index definition.

options
SuggestOptions

Options for filtering, sorting, and other suggestions query behaviors.

cancellationToken
CancellationToken

Optional CancellationToken to propagate notifications that the operation should be canceled.

Returns

Response containing suggestion query results from an index.

Exceptions

Thrown when a failure is returned by the Search Service.

Remarks

Suggest and SuggestAsync methods support mapping of search field types to .NET types via the type parameter T. You can provide your own type T or use the dynamic SearchDocument. See GetDocumentAsync<T>(String, GetDocumentOptions, CancellationToken) for more details on the type mapping.

Applies to

Toode Versioonid
Azure SDK for .NET Latest, Preview