SearchAsyncClient Class

  • java.lang.Object
    • com.azure.search.documents.SearchAsyncClient

public final class SearchAsyncClient

Initializes a new instance of the asynchronous SearchClient type.

Method Summary

Modifier and Type Method and Description
Mono<AutocompleteResult> autocomplete(AutocompleteOptions options)

Autocompletes incomplete query terms based on input text and matching terms in the index.

Mono<Response<AutocompleteResult>> autocompleteWithResponse(AutocompleteOptions options, RequestOptions requestOptions)

Autocompletes incomplete query terms based on input text and matching terms in the index.

Mono<LookupDocument> getDocument(String key)

Retrieves a document from the index.

Mono<LookupDocument> getDocument(String key, List<String> selectedFields)

Retrieves a document from the index.

Mono<Long> getDocumentCount()

Queries the number of documents in the index.

Mono<Response<Long>> getDocumentCountWithResponse(RequestOptions requestOptions)

Queries the number of documents in the index.

Mono<Response<LookupDocument>> getDocumentWithResponse(String key, RequestOptions requestOptions)

Retrieves a document from the index.

String getEndpoint()

Gets the endpoint used to communicate with the Azure AI Search service.

String getIndexName()

Gets the name of the Azure AI Search index.

SearchServiceVersion getServiceVersion()

Gets the SearchServiceVersion used to communicate with the Azure AI Search service.

Mono<IndexDocumentsResult> indexDocuments(IndexDocumentsBatch batch)

Sends a batch of document write actions to the index.

Mono<Response<IndexDocumentsResult>> indexDocumentsWithResponse(IndexDocumentsBatch batch, IndexDocumentsOptions options, RequestOptions requestOptions)

Sends a batch of document write actions to the index.

SearchPagedFlux search(SearchOptions options)

Searches for documents in the Azure AI Search index.

SearchPagedFlux search(SearchOptions options, RequestOptions requestOptions)

Searches for documents in the Azure AI Search index.

Mono<SuggestDocumentsResult> suggest(SuggestOptions options)

Suggests documents in the index that match the given partial query text.

Mono<Response<SuggestDocumentsResult>> suggestWithResponse(SuggestOptions options, RequestOptions requestOptions)

Suggests documents in the index that match the given partial query text.

Methods inherited from java.lang.Object

Method Details

autocomplete

public Mono<AutocompleteResult> autocomplete(AutocompleteOptions options)

Autocompletes incomplete query terms based on input text and matching terms in the index.

Parameters:

options - Options for autocomplete API.

Returns:

the result of Autocomplete query on successful completion of Mono.

autocompleteWithResponse

public Mono<Response<AutocompleteResult>> autocompleteWithResponse(AutocompleteOptions options, RequestOptions requestOptions)

Autocompletes incomplete query terms based on input text and matching terms in the index.

Parameters:

options - Options for autocomplete API.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

the result of Autocomplete query along with Response<T> on successful completion of Mono.

getDocument

public Mono<LookupDocument> getDocument(String key)

Retrieves a document from the index.

Parameters:

key - The key of the document to retrieve.

Returns:

a document retrieved via a document lookup operation on successful completion of Mono.

getDocument

public Mono<LookupDocument> getDocument(String key, List<String> selectedFields)

Retrieves a document from the index.

Parameters:

key - The key of the document to retrieve.
selectedFields - List of field names to retrieve for the document; Any field not retrieved will be missing from the returned document.

Returns:

a document retrieved via a document lookup operation on successful completion of Mono.

getDocumentCount

public Mono<Long> getDocumentCount()

Queries the number of documents in the index.

Returns:

a 64-bit integer on successful completion of Mono.

getDocumentCountWithResponse

public Mono<Response<Long>> getDocumentCountWithResponse(RequestOptions requestOptions)

Queries the number of documents in the index.

Parameters:

requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

a 64-bit integer along with Response<T> on successful completion of Mono.

getDocumentWithResponse

public Mono<Response<LookupDocument>> getDocumentWithResponse(String key, RequestOptions requestOptions)

Retrieves a document from the index.

Query Parameters

| ------- | ------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name    | Type         | Required | Description                                                                                                                                                |
| $select | List<String> | No       | List of field names to retrieve for the document; Any field not retrieved will be missing from the returned document. In the form of "," separated string. |

You can add these to a request with RequestOptions#addQueryParam

Header Parameters

| ------------------------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Name                            | Type    | Required | Description                                                                                                                         |
| x-ms-query-source-authorization | String  | No       | Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. |
| x-ms-enable-elevated-read       | Boolean | No       | A value that enables elevated read that bypass document level permission checks for the query operation.                            |

You can add these to a request with RequestOptions#addHeader

Parameters:

key - The key of the document to retrieve.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

a document retrieved via a document lookup operation along with Response<T> on successful completion of Mono.

getEndpoint

public String getEndpoint()

Gets the endpoint used to communicate with the Azure AI Search service.

Returns:

The endpoint.

getIndexName

public String getIndexName()

Gets the name of the Azure AI Search index.

Returns:

The index name.

getServiceVersion

public SearchServiceVersion getServiceVersion()

Gets the SearchServiceVersion used to communicate with the Azure AI Search service.

Returns:

The service version.

indexDocuments

public Mono<IndexDocumentsResult> indexDocuments(IndexDocumentsBatch batch)

Sends a batch of document write actions to the index.

Parameters:

batch - The batch of index actions.

Returns:

response containing the status of operations for all documents in the indexing request on successful completion of Mono.

indexDocumentsWithResponse

public Mono<Response<IndexDocumentsResult>> indexDocumentsWithResponse(IndexDocumentsBatch batch, IndexDocumentsOptions options, RequestOptions requestOptions)

Sends a batch of document write actions to the index.

Parameters:

batch - The batch of index actions.
options - Options that allow specifying document indexing behavior.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

response containing the status of operations for all documents in the indexing request on successful completion of Mono.

search

public SearchPagedFlux search(SearchOptions options)

Searches for documents in the Azure AI Search index.

The ContinuablePagedFlux will iterate through search result pages until all search results are returned. Each page is determined by the $skip and $top values and the Search service has a limit on the number of documents that can be skipped, more information about the $skip limit can be found at Search Documents REST API and reading the $skip description. If the total number of results exceeds the $skip limit the ContinuablePagedFlux won't prevent you from exceeding the $skip limit. To prevent exceeding the limit you can track the number of documents returned and stop requesting new pages when the limit is reached.

Parameters:

options - Options for search API.

Returns:

A ContinuablePagedFlux that iterates over search results and provides access to the SearchPagedResponse for each page containing HTTP response and count, facet, and coverage information.

search

public SearchPagedFlux search(SearchOptions options, RequestOptions requestOptions)

Searches for documents in the Azure AI Search index.

Header Parameters

| ------------------------------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Name                            | Type    | Required | Description                                                                                                                         |
| x-ms-query-source-authorization | String  | No       | Token identifying the user for which the query is being executed. This token is used to enforce security restrictions on documents. |
| x-ms-enable-elevated-read       | Boolean | No       | A value that enables elevated read that bypass document level permission checks for the query operation.                            |

You can add these to a request with RequestOptions#addHeader

The ContinuablePagedFlux will iterate through search result pages until all search results are returned. Each page is determined by the $skip and $top values and the Search service has a limit on the number of documents that can be skipped, more information about the $skip limit can be found at Search Documents REST API and reading the $skip description. If the total number of results exceeds the $skip limit the ContinuablePagedFlux won't prevent you from exceeding the $skip limit. To prevent exceeding the limit you can track the number of documents returned and stop requesting new pages when the limit is reached.

Parameters:

options - Options for search API.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

A ContinuablePagedFlux that iterates over search results and provides access to the SearchPagedResponse for each page containing HTTP response and count, facet, and coverage information.

suggest

public Mono<SuggestDocumentsResult> suggest(SuggestOptions options)

Suggests documents in the index that match the given partial query text.

Parameters:

options - Options for suggest API.

Returns:

response containing suggestion query results from an index on successful completion of Mono.

suggestWithResponse

public Mono<Response<SuggestDocumentsResult>> suggestWithResponse(SuggestOptions options, RequestOptions requestOptions)

Suggests documents in the index that match the given partial query text.

Parameters:

options - Options for suggest API.
requestOptions - The options to configure the HTTP request before HTTP client sends it.

Returns:

response containing suggestion query results from an index along with Response<T> on successful completion of Mono.

Applies to