SearchClient.SearchAsync 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.
Overloads
SearchAsync<T>(SearchOptions, CancellationToken) |
Searches for documents in the search index. Search Documents |
SearchAsync<T>(String, SearchOptions, CancellationToken) |
Searches for documents in the search index. Search Documents |
SearchAsync<T>(SearchOptions, CancellationToken)
- Source:
- SearchClient.cs
- Source:
- SearchClient.cs
Searches for documents in the search index. Search Documents
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Models.SearchResults<T>>> SearchAsync<T> (Azure.Search.Documents.SearchOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member SearchAsync : Azure.Search.Documents.SearchOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Models.SearchResults<'T>>>
override this.SearchAsync : Azure.Search.Documents.SearchOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Models.SearchResults<'T>>>
Public Overridable Function SearchAsync(Of T) (options As SearchOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of SearchResults(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
- options
- SearchOptions
Options that allow specifying filtering, sorting, faceting, paging, and other search query behaviors.
- cancellationToken
- CancellationToken
Optional CancellationToken to propagate notifications that the operation should be canceled.
Returns
Response containing the documents matching the query.
Exceptions
Thrown when a failure is returned by the Search Service.
Remarks
Search and SearchAsync 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.
Azure Cognitive Search might not be able to include all results in a single response in which case GetResultsAsync() will automatically continue making additional requests as you enumerate through the results. You can also process the results a page at a time with the AsPages(String, Nullable<Int32>) method.
Applies to
SearchAsync<T>(String, SearchOptions, CancellationToken)
- Source:
- SearchClient.cs
- Source:
- SearchClient.cs
Searches for documents in the search index. Search Documents
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Models.SearchResults<T>>> SearchAsync<T> (string searchText, Azure.Search.Documents.SearchOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member SearchAsync : string * Azure.Search.Documents.SearchOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Models.SearchResults<'T>>>
override this.SearchAsync : string * Azure.Search.Documents.SearchOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Search.Documents.Models.SearchResults<'T>>>
Public Overridable Function SearchAsync(Of T) (searchText As String, Optional options As SearchOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of SearchResults(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
A full-text search query expression; Use "*" or omit this parameter to match all documents. See Simple query syntax in Azure Cognitive Search for more information about search query syntax.
- options
- SearchOptions
Options that allow specifying filtering, sorting, faceting, paging, and other search query behaviors.
- cancellationToken
- CancellationToken
Optional CancellationToken to propagate notifications that the operation should be canceled.
Returns
Response containing the documents matching the query.
Exceptions
Thrown when a failure is returned by the Search Service.
Remarks
Search and SearchAsync 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.
Azure Cognitive Search might not be able to include all results in a single response in which case GetResultsAsync() will automatically continue making additional requests as you enumerate through the results. You can also process the results a page at a time with the AsPages(String, Nullable<Int32>) method.