public final class SearchIndexAsyncClient extends Object
SearchIndexClientBuilder
Modifier and Type | Method and Description |
---|---|
com.azure.core.http.rest.PagedFlux<AnalyzedTokenInfo> |
analyzeText(String indexName,
AnalyzeTextOptions analyzeTextOptions)
Shows how an analyzer breaks text into tokens.
|
static List<SearchField> |
buildSearchFields(Class<?> model,
FieldBuilderOptions options)
Convenience method to convert a
Class's Fields and Methods into SearchFields to help aid the creation of a SearchField which represents the Class . |
Mono<SearchIndex> |
createIndex(SearchIndex index)
Creates a new Azure Cognitive Search index.
|
Mono<com.azure.core.http.rest.Response<SearchIndex>> |
createIndexWithResponse(SearchIndex index)
Creates a new Azure Cognitive Search index.
|
Mono<SearchIndex> |
createOrUpdateIndex(SearchIndex index)
Creates a new Azure Cognitive Search index or updates an index if it already exists.
|
Mono<com.azure.core.http.rest.Response<SearchIndex>> |
createOrUpdateIndexWithResponse(SearchIndex index,
boolean allowIndexDowntime,
boolean onlyIfUnchanged)
Creates a new Azure Cognitive Search index or updates an index if it already exists.
|
Mono<SynonymMap> |
createOrUpdateSynonymMap(SynonymMap synonymMap)
Creates a new Azure Cognitive Search synonym map or updates a synonym map if it already exists.
|
Mono<com.azure.core.http.rest.Response<SynonymMap>> |
createOrUpdateSynonymMapWithResponse(SynonymMap synonymMap,
boolean onlyIfUnchanged)
Creates a new Azure Cognitive Search synonym map or updates a synonym map if it already exists.
|
Mono<SynonymMap> |
createSynonymMap(SynonymMap synonymMap)
Creates a new Azure Cognitive Search synonym map.
|
Mono<com.azure.core.http.rest.Response<SynonymMap>> |
createSynonymMapWithResponse(SynonymMap synonymMap)
Creates a new Azure Cognitive Search synonym map.
|
Mono<Void> |
deleteIndex(String indexName)
Deletes an Azure Cognitive Search index and all the documents it contains.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteIndexWithResponse(SearchIndex index,
boolean onlyIfUnchanged)
Deletes an Azure Cognitive Search index and all the documents it contains.
|
Mono<Void> |
deleteSynonymMap(String synonymMapName)
Deletes an Azure Cognitive Search synonym map.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteSynonymMapWithResponse(SynonymMap synonymMap,
boolean onlyIfUnchanged)
Deletes an Azure Cognitive Search synonym map.
|
String |
getEndpoint()
Gets the endpoint for the Azure Cognitive Search service.
|
Mono<SearchIndex> |
getIndex(String indexName)
Retrieves an index definition from the Azure Cognitive Search.
|
Mono<SearchIndexStatistics> |
getIndexStatistics(String indexName)
Returns statistics for the given index, including a document count and storage usage.
|
Mono<com.azure.core.http.rest.Response<SearchIndexStatistics>> |
getIndexStatisticsWithResponse(String indexName)
Returns statistics for the given index, including a document count and storage usage.
|
Mono<com.azure.core.http.rest.Response<SearchIndex>> |
getIndexWithResponse(String indexName)
Retrieves an index definition from the Azure Cognitive Search.
|
SearchAsyncClient |
getSearchAsyncClient(String indexName)
Initializes a new
SearchAsyncClient using the given Index name and the same configuration as the
SearchServiceAsyncClient. |
Mono<SearchServiceStatistics> |
getServiceStatistics()
Returns service level statistics for a search service, including service counters and limits.
|
Mono<com.azure.core.http.rest.Response<SearchServiceStatistics>> |
getServiceStatisticsWithResponse()
Returns service level statistics for a search service, including service counters and limits.
|
Mono<SynonymMap> |
getSynonymMap(String synonymMapName)
Retrieves a synonym map definition.
|
Mono<com.azure.core.http.rest.Response<SynonymMap>> |
getSynonymMapWithResponse(String synonymMapName)
Retrieves a synonym map definition.
|
com.azure.core.http.rest.PagedFlux<SearchIndex> |
listIndexes()
Lists all indexes available for an Azure Cognitive Search service.
|
com.azure.core.http.rest.PagedFlux<String> |
listIndexNames()
Lists all indexes names for an Azure Cognitive Search service.
|
com.azure.core.http.rest.PagedFlux<String> |
listSynonymMapNames()
Lists all synonym map names for an Azure Cognitive Search service.
|
com.azure.core.http.rest.PagedFlux<SynonymMap> |
listSynonymMaps()
Lists all synonym maps available for an Azure Cognitive Search service.
|
public String getEndpoint()
public SearchAsyncClient getSearchAsyncClient(String indexName)
SearchAsyncClient
using the given Index name and the same configuration as the
SearchServiceAsyncClient.indexName
- the name of the Index for the clientSearchAsyncClient
created from the service client configurationpublic Mono<SearchIndex> createIndex(SearchIndex index)
Code Sample
Create search index named "searchIndex".
List<SearchField> searchFields = Arrays.asList( new SearchField("hotelId", SearchFieldDataType.STRING).setKey(true), new SearchField("hotelName", SearchFieldDataType.STRING).setSearchable(true) ); SearchIndex searchIndex = new SearchIndex("searchIndex", searchFields); searchIndexAsyncClient.createIndex(searchIndex) .subscribe(indexFromService -> System.out.printf("The index name is %s. The ETag of index is %s.%n", indexFromService.getName(), indexFromService.getETag()));
index
- definition of the index to create.public Mono<com.azure.core.http.rest.Response<SearchIndex>> createIndexWithResponse(SearchIndex index)
Code Sample
Create search index named "searchIndex".
List<SearchField> searchFields = Arrays.asList( new SearchField("hotelId", SearchFieldDataType.STRING).setKey(true), new SearchField("hotelName", SearchFieldDataType.STRING).setSearchable(true) ); SearchIndex searchIndex = new SearchIndex("searchIndex", searchFields); searchIndexAsyncClient.createIndexWithResponse(searchIndex) .subscribe(indexFromServiceResponse -> System.out.printf("The status code of the response is %s. The index name is %s.%n", indexFromServiceResponse.getStatusCode(), indexFromServiceResponse.getValue().getName()));
index
- definition of the index to createpublic Mono<SearchIndex> getIndex(String indexName)
Code Sample
Get search index with name "searchIndex".
searchIndexAsyncClient.getIndex("searchIndex") .subscribe(indexFromService -> System.out.printf("The index name is %s. The ETag of index is %s.%n", indexFromService.getName(), indexFromService.getETag()));
indexName
- The name of the index to retrievepublic Mono<com.azure.core.http.rest.Response<SearchIndex>> getIndexWithResponse(String indexName)
Code Sample
Get search index with "searchIndex.
searchIndexAsyncClient.getIndexWithResponse("searchIndex") .subscribe(indexFromServiceResponse -> System.out.printf("The status code of the response is %s. The index name is %s.%n", indexFromServiceResponse.getStatusCode(), indexFromServiceResponse.getValue().getName()));
indexName
- the name of the index to retrievepublic Mono<SearchIndexStatistics> getIndexStatistics(String indexName)
Code Sample
Get search index "searchIndex" statistics.
searchIndexAsyncClient.getIndexStatistics("searchIndex") .subscribe(statistics -> System.out.printf("There are %d documents and storage size of %d available in 'searchIndex'.%n", statistics.getDocumentCount(), statistics.getStorageSize()));
indexName
- the name of the index for which to retrieve statisticspublic Mono<com.azure.core.http.rest.Response<SearchIndexStatistics>> getIndexStatisticsWithResponse(String indexName)
Code Sample
Get search index "searchIndex" statistics.
searchIndexAsyncClient.getIndexStatisticsWithResponse("searchIndex") .subscribe(statistics -> System.out.printf("The status code of the response is %s.%n" + "There are %d documents and storage size of %d available in 'searchIndex'.%n", statistics.getStatusCode(), statistics.getValue().getDocumentCount(), statistics.getValue().getStorageSize()));
indexName
- the name of the index for which to retrieve statisticspublic com.azure.core.http.rest.PagedFlux<SearchIndex> listIndexes()
Code Sample
List all search indexes.
searchIndexAsyncClient.listIndexes() .subscribe(index -> System.out.printf("The index name is %s. The ETag of index is %s.%n", index.getName(), index.getETag()));
public com.azure.core.http.rest.PagedFlux<String> listIndexNames()
Code Sample
List all search indexes names.
searchIndexAsyncClient.listIndexNames() .subscribe(indexName -> System.out.printf("The index name is %s.%n", indexName));
public Mono<SearchIndex> createOrUpdateIndex(SearchIndex index)
Code Sample
Create or update search index named "searchIndex".
searchIndexAsyncClient.getIndex("searchIndex") .doOnNext(indexFromService -> indexFromService.setSuggesters(Collections.singletonList( new SearchSuggester("sg", Collections.singletonList("hotelName"))))) .flatMap(searchIndexAsyncClient::createOrUpdateIndex) .subscribe(updatedIndex -> System.out.printf("The index name is %s. The suggester name of index is %s.%n", updatedIndex.getName(), updatedIndex.getSuggesters().get(0).getName()));
index
- the definition of the SearchIndex
to create or update.public Mono<com.azure.core.http.rest.Response<SearchIndex>> createOrUpdateIndexWithResponse(SearchIndex index, boolean allowIndexDowntime, boolean onlyIfUnchanged)
Code Sample
Create or update search index named "searchIndex".
SearchIndex indexFromService = searchIndexClient.getIndex("searchIndex"); indexFromService.setSuggesters(Collections.singletonList(new SearchSuggester("sg", Collections.singletonList("hotelName")))); Response<SearchIndex> updatedIndexResponse = searchIndexClient.createOrUpdateIndexWithResponse(indexFromService, true, false, new Context(key1, value1)); System.out.printf("The status code of the normal response is %s.%n" + "The index name is %s. The ETag of index is %s.%n", updatedIndexResponse.getStatusCode(), updatedIndexResponse.getValue().getName(), updatedIndexResponse.getValue().getETag());
index
- the definition of the index to create or updateallowIndexDowntime
- allows new analyzers, tokenizers, token filters, or char filters to be added to an
index by taking the index offline for at least a few seconds. This temporarily causes indexing and query requests
to fail. Performance and write availability of the index can be impaired for several minutes after the index is
updated, or longer for very large indexesonlyIfUnchanged
- true
to update if the index
is the same as the current service value.
false
to always update existing value.public Mono<Void> deleteIndex(String indexName)
Code Sample
Delete search index with name "searchIndex".
searchIndexAsyncClient.deleteIndex("searchIndex") .subscribe();
indexName
- the name of the index to deletepublic Mono<com.azure.core.http.rest.Response<Void>> deleteIndexWithResponse(SearchIndex index, boolean onlyIfUnchanged)
Code Sample
Delete search index with name "searchIndex".
searchIndexAsyncClient.getIndex("searchIndex") .flatMap(indexFromService -> searchIndexAsyncClient.deleteIndexWithResponse(indexFromService, true)) .subscribe(deleteResponse -> System.out.printf("The status code of the response is %d.%n", deleteResponse.getStatusCode()));
index
- the SearchIndex
to delete.onlyIfUnchanged
- true
to delete if the index
is the same as the current service value.
false
to always delete existing value.public com.azure.core.http.rest.PagedFlux<AnalyzedTokenInfo> analyzeText(String indexName, AnalyzeTextOptions analyzeTextOptions)
Code Sample
Analyzer text with LexicalTokenizerName "Classic" in search index "searchIndex".
searchIndexAsyncClient.analyzeText("searchIndex", new AnalyzeTextOptions("The quick brown fox", LexicalTokenizerName.CLASSIC)) .subscribe(tokenInfo -> System.out.printf("The token emitted by the analyzer is %s.%n", tokenInfo.getToken()));
indexName
- the name of the index for which to test an analyzeranalyzeTextOptions
- the text and analyzer or analysis components to testpublic Mono<SynonymMap> createSynonymMap(SynonymMap synonymMap)
Code Sample
Create synonym map named "synonymMap".
SynonymMap synonymMap = new SynonymMap("synonymMap", "United States, United States of America, USA\nWashington, Wash. => WA"); searchIndexAsyncClient.createSynonymMap(synonymMap) .subscribe(synonymMapFromService -> System.out.printf("The synonym map name is %s. The ETag of synonym map is %s.%n", synonymMapFromService.getName(), synonymMapFromService.getETag()));
synonymMap
- the definition of the synonym map to createSynonymMap
.public Mono<com.azure.core.http.rest.Response<SynonymMap>> createSynonymMapWithResponse(SynonymMap synonymMap)
Code Sample
Create synonym map named "synonymMap".
SynonymMap synonymMap = new SynonymMap("synonymMap", "United States, United States of America, USA\nWashington, Wash. => WA"); searchIndexAsyncClient.createSynonymMapWithResponse(synonymMap) .subscribe(synonymMapFromService -> System.out.printf("The status code of the response is %d.%n" + "The synonym map name is %s. The ETag of synonym map is %s.%n", synonymMapFromService.getStatusCode(), synonymMapFromService.getValue().getName(), synonymMapFromService.getValue().getETag()));
synonymMap
- the definition of the SynonymMap
to createpublic Mono<SynonymMap> getSynonymMap(String synonymMapName)
Code Sample
Get synonym map with name "synonymMap".
searchIndexAsyncClient.getSynonymMap("synonymMap") .subscribe(synonymMapFromService -> System.out.printf("The synonym map is %s. The ETag of synonym map is %s.%n", synonymMapFromService.getName(), synonymMapFromService.getETag()));
synonymMapName
- name of the synonym map to retrieveSynonymMap
definitionpublic Mono<com.azure.core.http.rest.Response<SynonymMap>> getSynonymMapWithResponse(String synonymMapName)
Code Sample
Get synonym map with name "synonymMap".
searchIndexAsyncClient.getSynonymMap("synonymMap") .subscribe(synonymMapFromService -> System.out.printf("The synonym map is %s. The ETag of synonym map is %s.%n", synonymMapFromService.getName(), synonymMapFromService.getETag()));
synonymMapName
- name of the synonym map to retrievepublic com.azure.core.http.rest.PagedFlux<SynonymMap> listSynonymMaps()
Code Sample
List all synonym maps.
searchIndexAsyncClient.listSynonymMaps() .subscribe(synonymMap -> System.out.printf("The synonymMap name is %s. The ETag of synonymMap is %s.%n", synonymMap.getName(), synonymMap.getETag()));
public com.azure.core.http.rest.PagedFlux<String> listSynonymMapNames()
Code Sample
List all synonym map names.
searchIndexAsyncClient.listSynonymMapNames() .subscribe(synonymMap -> System.out.printf("The synonymMap name is %s.%n", synonymMap));
public Mono<SynonymMap> createOrUpdateSynonymMap(SynonymMap synonymMap)
Code Sample
Create or update synonym map named "synonymMap".
searchIndexAsyncClient.getSynonymMap("searchIndex") .doOnNext(synonymMap -> synonymMap .setSynonyms("United States, United States of America, USA, America\nWashington, Wash. => WA")) .flatMap(searchIndexAsyncClient::createOrUpdateSynonymMap) .subscribe(updatedSynonymMap -> System.out.printf("The synonym map name is %s. The synonyms are %s.%n", updatedSynonymMap.getName(), updatedSynonymMap.getSynonyms()));
synonymMap
- the definition of the SynonymMap
to create or updatepublic Mono<com.azure.core.http.rest.Response<SynonymMap>> createOrUpdateSynonymMapWithResponse(SynonymMap synonymMap, boolean onlyIfUnchanged)
Code Sample
Create or update synonym map named "synonymMap".
searchIndexAsyncClient.getSynonymMap("searchIndex") .flatMap(synonymMap -> { synonymMap.setSynonyms( "United States, United States of America, USA, America\nWashington, Wash. => WA"); return searchIndexAsyncClient.createOrUpdateSynonymMapWithResponse(synonymMap, true); }) .subscribe(updatedSynonymMap -> System.out.printf("The status code of the normal response is %s.%n" + "The synonym map name is %s. The synonyms are %s.%n", updatedSynonymMap.getStatusCode(), updatedSynonymMap.getValue().getName(), updatedSynonymMap.getValue().getSynonyms()));
synonymMap
- the definition of the SynonymMap
to create or updateonlyIfUnchanged
- true
to update if the synonymMap
is the same as the current service value.
false
to always update existing value.public Mono<Void> deleteSynonymMap(String synonymMapName)
Code Sample
Delete synonym map with name "synonymMap".
searchIndexAsyncClient.deleteSynonymMap("synonymMap") .subscribe();
synonymMapName
- the name of the SynonymMap
to deletepublic Mono<com.azure.core.http.rest.Response<Void>> deleteSynonymMapWithResponse(SynonymMap synonymMap, boolean onlyIfUnchanged)
Code Sample
Delete synonym map with name "synonymMap".
searchIndexAsyncClient.getSynonymMap("synonymMap") .flatMap(synonymMap -> searchIndexAsyncClient.deleteSynonymMapWithResponse(synonymMap, true)) .subscribe(response -> System.out.println("The status code of the response is" + response.getStatusCode()));
synonymMap
- the SynonymMap
to delete.onlyIfUnchanged
- true
to delete if the synonymMap
is the same as the current service value.
false
to always delete existing value.public static List<SearchField> buildSearchFields(Class<?> model, FieldBuilderOptions options)
Class's
Fields
and Methods
into SearchFields
to help aid the creation of a SearchField
which represents the Class
.model
- The model Class
that will have SearchFields
generated from its
structure.options
- Configuration used to determine generation of the SearchFields
.SearchFields
which represent the model Class
.public Mono<SearchServiceStatistics> getServiceStatistics()
Contains the tracking ID sent with the request to help with debugging
Code Sample
Get service statistics.
searchIndexAsyncClient.getServiceStatistics() .subscribe(serviceStatistics -> System.out.printf("There are %s search indexes in your service.%n", serviceStatistics.getCounters().getIndexCounter()));
public Mono<com.azure.core.http.rest.Response<SearchServiceStatistics>> getServiceStatisticsWithResponse()
Code Sample
Get service statistics.
searchIndexAsyncClient.getServiceStatisticsWithResponse() .subscribe(serviceStatistics -> System.out.printf("The status code of the response is %s.%n" + "There are %s search indexes in your service.%n", serviceStatistics.getStatusCode(), serviceStatistics.getValue().getCounters().getIndexCounter()));
Copyright © 2021 Microsoft Corporation. All rights reserved.