Udostępnij za pośrednictwem


SearchClient.Suggest<T> Method

Definition

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

public virtual Azure.Response<Azure.Search.Documents.Models.SuggestResults<T>> Suggest<T> (string searchText, string suggesterName, Azure.Search.Documents.SuggestOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member Suggest : string * string * Azure.Search.Documents.SuggestOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Search.Documents.Models.SuggestResults<'T>>
override this.Suggest : string * string * Azure.Search.Documents.SuggestOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Search.Documents.Models.SuggestResults<'T>>
Public Overridable Function Suggest(Of T) (searchText As String, suggesterName As String, Optional options As SuggestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of SuggestResults(Of T))

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