SearchClient Class
- java.
lang. Object - com.
azure. search. documents. SearchClient
- com.
public final class SearchClient
Initializes a new instance of the synchronous SearchClient type.
Method Summary
Methods inherited from java.lang.Object
Method Details
autocomplete
public AutocompleteResult autocomplete(AutocompleteOptions options)
Autocompletes incomplete query terms based on input text and matching terms in the index.
Parameters:
Returns:
autocompleteWithResponse
public Response<AutocompleteResult> autocompleteWithResponse(AutocompleteOptions options, RequestOptions requestOptions)
Autocompletes incomplete query terms based on input text and matching terms in the index.
Parameters:
Returns:
getDocument
public LookupDocument getDocument(String key)
Retrieves a document from the index.
Parameters:
Returns:
getDocument
public LookupDocument getDocument(String key, List<String> selectedFields)
Retrieves a document from the index.
Parameters:
Returns:
getDocumentCount
public long getDocumentCount()
Queries the number of documents in the index.
Returns:
getDocumentCountWithResponse
public Response<Long> getDocumentCountWithResponse(RequestOptions requestOptions)
Queries the number of documents in the index.
Parameters:
Returns:
getDocumentWithResponse
public 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:
Returns:
getEndpoint
public String getEndpoint()
Gets the endpoint used to communicate with the Azure AI Search service.
Returns:
getIndexName
public String getIndexName()
Gets the name of the Azure AI Search index.
Returns:
getServiceVersion
public SearchServiceVersion getServiceVersion()
Gets the SearchServiceVersion used to communicate with the Azure AI Search service.
Returns:
indexDocuments
public IndexDocumentsResult indexDocuments(IndexDocumentsBatch batch)
Sends a batch of document write actions to the index.
Parameters:
Returns:
indexDocumentsWithResponse
public Response<IndexDocumentsResult> indexDocumentsWithResponse(IndexDocumentsBatch batch, IndexDocumentsOptions options, RequestOptions requestOptions)
Sends a batch of document write actions to the index.
Parameters:
Returns:
search
public SearchPagedIterable search(SearchOptions options)
Searches for documents in the Azure AI Search index.
The ContinuablePagedIterable<C,T,P> 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 ContinuablePagedIterable<C,T,P> 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:
Returns:
search
public SearchPagedIterable 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 ContinuablePagedIterable<C,T,P> 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 ContinuablePagedIterable<C,T,P> 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:
Returns:
suggest
public SuggestDocumentsResult suggest(SuggestOptions options)
Suggests documents in the index that match the given partial query text.
Parameters:
Returns:
suggestWithResponse
public Response<SuggestDocumentsResult> suggestWithResponse(SuggestOptions options, RequestOptions requestOptions)
Suggests documents in the index that match the given partial query text.
Parameters:
Returns: