public final class SearchIndexClient extends Object
Modifier and Type | Method and Description |
---|---|
AutocompletePagedIterable |
autocomplete(String searchText,
String suggesterName)
Autocompletes incomplete query terms based on input text and matching terms in the index.
|
AutocompletePagedIterable |
autocomplete(String searchText,
String suggesterName,
AutocompleteOptions autocompleteOptions,
RequestOptions requestOptions,
Context context)
Autocompletes incomplete query terms based on input text and matching terms in the index.
|
IndexDocumentsResult |
deleteDocuments(Iterable<?> documents)
Deletes a collection of documents from the target index.
|
Response<IndexDocumentsResult> |
deleteDocumentsWithResponse(Iterable<?> documents,
Context context)
Deletes a collection of documents from the target index.
|
SearchDocument |
getDocument(String key)
Retrieves a document from the Azure Cognitive Search index.
|
long |
getDocumentCount()
Queries the number of documents in the search index.
|
Response<Long> |
getDocumentCountWithResponse(Context context)
Queries the number of documents in the search index.
|
Response<SearchDocument> |
getDocumentWithResponse(String key,
List<String> selectedFields,
RequestOptions requestOptions,
Context context)
Retrieves a document from the Azure Cognitive Search index.
|
String |
getEndpoint()
Gets the endpoint for the Azure Cognitive Search service.
|
String |
getIndexName()
Gets the name of the Azure Cognitive Search index.
|
SearchServiceVersion |
getServiceVersion()
Gets the version of the Search service the client is using.
|
IndexDocumentsResult |
indexDocuments(IndexDocumentsBatch<?> batch)
Sends a batch of upload, merge, and/or delete actions to the search index.
|
Response<IndexDocumentsResult> |
indexDocumentsWithResponse(IndexDocumentsBatch<?> batch,
Context context)
Sends a batch of upload, merge, and/or delete actions to the search index.
|
IndexDocumentsResult |
mergeDocuments(Iterable<?> documents)
Merges a collection of documents with existing documents in the target index.
|
Response<IndexDocumentsResult> |
mergeDocumentsWithResponse(Iterable<?> documents,
Context context)
Merges a collection of documents with existing documents in the target index.
|
IndexDocumentsResult |
mergeOrUploadDocuments(Iterable<?> documents)
This action behaves like merge if a document with the given key already exists in the index.
|
Response<IndexDocumentsResult> |
mergeOrUploadDocumentsWithResponse(Iterable<?> documents,
Context context)
This action behaves like merge if a document with the given key already exists in the index.
|
SearchPagedIterable |
search(String searchText)
Searches for documents in the Azure Cognitive Search index.
|
SearchPagedIterable |
search(String searchText,
SearchOptions searchOptions,
RequestOptions requestOptions,
Context context)
Searches for documents in the Azure Cognitive Search index.
|
SuggestPagedIterable |
suggest(String searchText,
String suggesterName)
Suggests documents in the index that match the given partial query.
|
SuggestPagedIterable |
suggest(String searchText,
String suggesterName,
SuggestOptions suggestOptions,
RequestOptions requestOptions,
Context context)
Suggests documents in the index that match the given partial query.
|
IndexDocumentsResult |
uploadDocuments(Iterable<?> documents)
Uploads a collection of documents to the target index.
|
Response<IndexDocumentsResult> |
uploadDocumentsWithResponse(Iterable<?> documents,
Context context)
Uploads a collection of documents to the target index.
|
public String getIndexName()
public IndexDocumentsResult uploadDocuments(Iterable<?> documents)
documents
- collection of documents to upload to the target Index.IndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public Response<IndexDocumentsResult> uploadDocumentsWithResponse(Iterable<?> documents, Context context)
documents
- collection of documents to upload to the target Index.context
- additional context that is passed through the Http pipeline during the service callIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public IndexDocumentsResult mergeDocuments(Iterable<?> documents)
If the type of the document contains non-nullable primitive-typed properties, these properties may not merge
correctly. If you do not set such a property, it will automatically take its default value (for example, 0
for int
or false
for boolean
), which will override the value of the property currently
stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you
always declare primitive-typed properties with their class equivalents (for example, an integer property should
be of type Integer
instead of int
).
documents
- collection of documents to be mergedIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public Response<IndexDocumentsResult> mergeDocumentsWithResponse(Iterable<?> documents, Context context)
If the type of the document contains non-nullable primitive-typed properties, these properties may not merge
correctly. If you do not set such a property, it will automatically take its default value (for example, 0
for int
or false
for boolean
), which will override the value of the property currently
stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you
always declare primitive-typed properties with their class equivalents (for example, an integer property should
be of type Integer
instead of int
).
documents
- collection of documents to be mergedcontext
- additional context that is passed through the Http pipeline during the service callIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public IndexDocumentsResult mergeOrUploadDocuments(Iterable<?> documents)
If the type of the document contains non-nullable primitive-typed properties, these properties may not merge
correctly. If you do not set such a property, it will automatically take its default value (for example, 0
for int
or false
for boolean
), which will override the value of the property currently
stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you
always declare primitive-typed properties with their class equivalents (for example, an integer property should
be of type Integer
instead of int
).
documents
- collection of documents to be merged, if exists, otherwise uploadedIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public Response<IndexDocumentsResult> mergeOrUploadDocumentsWithResponse(Iterable<?> documents, Context context)
If the type of the document contains non-nullable primitive-typed properties, these properties may not merge
correctly. If you do not set such a property, it will automatically take its default value (for example, 0
for int
or false
for boolean
), which will override the value of the property currently
stored in the index, even if this was not your intent. For this reason, it is strongly recommended that you
always declare primitive-typed properties with their class equivalents (for example, an integer property should
be of type Integer
instead of int
).
documents
- collection of documents to be merged, if exists, otherwise uploadedcontext
- additional context that is passed through the Http pipeline during the service callIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public IndexDocumentsResult deleteDocuments(Iterable<?> documents)
documents
- collection of documents to delete from the target Index. Fields other than the key are ignored.IndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public Response<IndexDocumentsResult> deleteDocumentsWithResponse(Iterable<?> documents, Context context)
documents
- collection of documents to delete from the target Index. Fields other than the key are ignored.context
- additional context that is passed through the Http pipeline during the service callIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public SearchServiceVersion getServiceVersion()
public String getEndpoint()
public long getDocumentCount()
public Response<Long> getDocumentCountWithResponse(Context context)
context
- additional context that is passed through the Http pipeline during the service callpublic SearchPagedIterable search(String searchText)
If searchText
is set to null
or "*"
all documents will be matched, see
simple query
syntax in Azure Search for more information about search query syntax.
searchText
- A full-text search query expression.SearchPagedIterable
that iterates over SearchResult
objects and provides access to the
SearchPagedResponse
object for each page containing HTTP response and count, facet, and coverage
information.public SearchPagedIterable search(String searchText, SearchOptions searchOptions, RequestOptions requestOptions, Context context)
If searchText
is set to null
or "*"
all documents will be matched, see
simple query
syntax in Azure Search for more information about search query syntax.
searchText
- A full-text search query expression.searchOptions
- Parameters to further refine the search queryrequestOptions
- additional parameters for the operation. Contains the tracking ID sent with the request to
help with debuggingcontext
- additional context that is passed through the Http pipeline during the service callSearchPagedIterable
that iterates over SearchResult
objects and provides access to the
SearchPagedResponse
object for each page containing HTTP response and count, facet, and coverage
information.public SearchDocument getDocument(String key)
View naming rules for guidelines on constructing valid document keys.
key
- The key of the document to retrieve.public Response<SearchDocument> getDocumentWithResponse(String key, List<String> selectedFields, RequestOptions requestOptions, Context context)
View naming rules for guidelines on constructing valid document keys.
key
- The key of the document to retrieve.selectedFields
- List of field names to retrieve for the document; Any field not retrieved will have null or
default as its corresponding property value in the returned object.requestOptions
- additional parameters for the operation. Contains the tracking ID sent with the request to
help with debuggingcontext
- additional context that is passed through the Http pipeline during the service callpublic SuggestPagedIterable suggest(String searchText, String suggesterName)
searchText
- The search text on which to base suggestionssuggesterName
- The name of the suggester as specified in the suggesters collection that's part of the index
definitionSuggestPagedIterable
that iterates over SuggestResult
objects and provides access to
the SuggestPagedResponse
object for each page containing HTTP response and coverage information.public SuggestPagedIterable suggest(String searchText, String suggesterName, SuggestOptions suggestOptions, RequestOptions requestOptions, Context context)
searchText
- The search text on which to base suggestionssuggesterName
- The name of the suggester as specified in the suggesters collection that's part of the index
definitionsuggestOptions
- Parameters to further refine the suggestion query.requestOptions
- additional parameters for the operation. Contains the tracking ID sent with the request to
help with debuggingcontext
- additional context that is passed through the Http pipeline during the service callSuggestPagedIterable
that iterates over SuggestResult
objects and provides access to
the SuggestPagedResponse
object for each page containing HTTP response and coverage information.public IndexDocumentsResult indexDocuments(IndexDocumentsBatch<?> batch)
batch
- The batch of index actionsIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public Response<IndexDocumentsResult> indexDocumentsWithResponse(IndexDocumentsBatch<?> batch, Context context)
batch
- The batch of index actionscontext
- additional context that is passed through the Http pipeline during the service callIndexBatchException
- If some of the indexing actions fail but other actions succeed and modify the state
of the index. This can happen when the Search Service is under heavy indexing load. It is important to explicitly
catch this exception and check the return value IndexBatchException.getIndexingResults()
. The indexing
result reports the status of each indexing action in the batch, making it possible to determine the state of the
index after a partial failure.public AutocompletePagedIterable autocomplete(String searchText, String suggesterName)
searchText
- search textsuggesterName
- suggester namepublic AutocompletePagedIterable autocomplete(String searchText, String suggesterName, AutocompleteOptions autocompleteOptions, RequestOptions requestOptions, Context context)
searchText
- search textsuggesterName
- suggester nameautocompleteOptions
- autocomplete optionsrequestOptions
- additional parameters for the operation. Contains the tracking ID sent with the request to
help with debuggingcontext
- additional context that is passed through the HTTP pipeline during the service callCopyright © 2020 Microsoft Corporation. All rights reserved.