SearchIndexerClient Class
- java.
lang. Object - com.
azure. search. documents. indexes. SearchIndexerClient
- com.
public class SearchIndexerClient
This class provides a client that contains the operations for creating, getting, listing, updating, or deleting data source connections, indexers, or skillsets and running or resetting indexers in an Azure AI Search service.
Overview
Indexers provide indexing automation. An indexer connects to a data source, reads in the data, and passes it to a skillset pipeline for indexing into a target search index. Indexers read from an external source using connection information in a data source, and serialize the incoming data into JSON search documents. In addition to a data source, an indexer also requires an index. The index specifies the fields and attributes of the search documents.
A skillset adds external processing steps to indexer execution, and is usually used to add AI or deep learning models to analyze or transform content to make it searchable in an index. The contents of a skillset are one or more skills, which can be built-in skills created by Microsoft, custom skills, or a combination of both. Built-in skills exist for image analysis, including OCR, and natural language processing. Other examples of built-in skills include entity recognition, key phrase extraction, chunking text into logical pages, among others. A skillset is high-level standalone object that exists on a level equivalent to indexes, indexers, and data sources, but it's operational only within indexer processing. As a high-level object, you can design a skillset once, and then reference it in multiple indexers.
This client provides a synchronous API for accessing indexers and skillsets. This client allows you to create, update, list, or delete indexers and skillsets. It can also be used to run or reset indexers.
Getting Started
Authenticating and building instances of this client are handled by SearchIndexerClientBuilder. This sample shows you how to authenticate and build this client:
SearchIndexerClient searchIndexerClient = new SearchIndexerClientBuilder()
.endpoint("{endpoint}")
.credential(new AzureKeyCredential("{admin-key}"))
.buildClient();
For more information on authentication and building, see the SearchIndexerClientBuilder documentation.
Examples
The following examples all use a simple Hotel data set that you can import into your own index from the Azure portal. These are just a few of the basics - please check out our Samples for much more.
Create an Indexer
The following sample creates an indexer.
SearchIndexer indexer = new SearchIndexer("example-indexer", "example-datasource", "example-index");
SearchIndexer createdIndexer = searchIndexerClient.createIndexer(indexer);
System.out.printf("Created indexer name: %s%n", createdIndexer.getName());
For an asynchronous sample, see createIndexer(SearchIndexer indexer).
List all Indexers
The following sample lists all indexers.
searchIndexerClient.listIndexers().forEach(indexer ->
System.out.printf("Retrieved indexer name: %s%n", indexer.getName())
);
For an asynchronous sample, see listIndexers().
Get an Indexer
The following sample gets an indexer.
SearchIndexer indexer = searchIndexerClient.getIndexer("example-indexer");
System.out.printf("Retrieved indexer name: %s%n", indexer.getName());
For an asynchronous sample, see getIndexer(String indexerName).
Update an Indexer
The following sample updates an indexer.
SearchIndexer indexer = searchIndexerClient.getIndexer("example-indexer");
indexer.setDescription("This is a new description for this indexer");
SearchIndexer updatedIndexer = searchIndexerClient.createOrUpdateIndexer(indexer);
System.out.printf("Updated indexer name: %s, description: %s%n", updatedIndexer.getName(),
updatedIndexer.getDescription());
For an asynchronous sample, see createOrUpdateIndexer(SearchIndexer indexer).
Delete an Indexer
The following sample deletes an indexer.
searchIndexerClient.deleteIndexer("example-indexer");
For an asynchronous sample, see deleteIndexer(String indexerName).
Run an Indexer
The following sample runs an indexer.
searchIndexerClient.runIndexer("example-indexer");
For an asynchronous sample, see runIndexer(String indexerName).
Reset an Indexer
The following sample resets an indexer.
searchIndexerClient.resetIndexer("example-indexer");
For an asynchronous sample, see resetIndexer(String indexerName).
Create a Skillset
The following sample creates a skillset.
List<InputFieldMappingEntry> inputs = Collections.singletonList(
new InputFieldMappingEntry("image")
.setSource("/document/normalized_images/*")
);
List<OutputFieldMappingEntry> outputs = Arrays.asList(
new OutputFieldMappingEntry("text")
.setTargetName("mytext"),
new OutputFieldMappingEntry("layoutText")
.setTargetName("myLayoutText")
);
List<SearchIndexerSkill> skills = Collections.singletonList(
new OcrSkill(inputs, outputs)
.setShouldDetectOrientation(true)
.setDefaultLanguageCode(null)
.setName("myocr")
.setDescription("Extracts text (plain and structured) from image.")
.setContext("/document/normalized_images/*")
);
SearchIndexerSkillset skillset = new SearchIndexerSkillset("skillsetName", skills)
.setDescription("Extracts text (plain and structured) from image.");
System.out.println(String.format("Creating OCR skillset '%s'", skillset.getName()));
SearchIndexerSkillset createdSkillset = searchIndexerClient.createSkillset(skillset);
System.out.println("Created OCR skillset");
System.out.println(String.format("Name: %s", createdSkillset.getName()));
System.out.println(String.format("ETag: %s", createdSkillset.getETag()));
For an asynchronous sample, see createSkillset(SearchIndexerSkillset skillset).
List all Skillsets
The following sample lists all skillsets.
searchIndexerClient.listSkillsets().forEach(skillset ->
System.out.printf("Retrieved skillset name: %s%n", skillset.getName())
);
For an asynchronous sample, see listSkillsets().
Get a Skillset
The following sample gets a skillset.
SearchIndexerSkillset skillset = searchIndexerClient.getSkillset("example-skillset");
System.out.printf("Retrieved skillset name: %s%n", skillset.getName());
For an asynchronous sample, see getSkillset(String skillsetName).
Update a Skillset
The following sample updates a skillset.
SearchIndexerSkillset skillset = searchIndexerClient.getSkillset("example-skillset");
skillset.setDescription("This is a new description for this skillset");
SearchIndexerSkillset updatedSkillset = searchIndexerClient.createOrUpdateSkillset(skillset);
System.out.printf("Updated skillset name: %s, description: %s%n", updatedSkillset.getName(),
updatedSkillset.getDescription());
For an asynchronous sample, see createOrUpdateSkillset(SearchIndexerSkillset skillset).
Delete a Skillset
The following sample deletes a skillset.
searchIndexerClient.deleteSkillset("example-skillset");
For an asynchronous sample, see deleteSkillset(String skillsetName).
Method Summary
Methods inherited from java.lang.Object
Method Details
createDataSourceConnection
public SearchIndexerDataSourceConnection createDataSourceConnection(SearchIndexerDataSourceConnection dataSourceConnection)
Creates a new Azure AI Search data source
Code Sample
Create search indexer data source connection named "dataSource".
SearchIndexerDataSourceConnection dataSource = new SearchIndexerDataSourceConnection("dataSource",
com.azure.search.documents.indexes.models.SearchIndexerDataSourceType.AZURE_BLOB, "{connectionString}",
new com.azure.search.documents.indexes.models.SearchIndexerDataContainer("container"));
SearchIndexerDataSourceConnection dataSourceFromService =
SEARCH_INDEXER_CLIENT.createDataSourceConnection(dataSource);
System.out.printf("The data source name is %s. The ETag of data source is %s.%n",
dataSourceFromService.getName(), dataSourceFromService.getETag());
Parameters:
Returns:
createDataSourceConnectionWithResponse
public Response
Creates a new Azure AI Search data source
Code Sample
Create search indexer data source connection named "dataSource".
SearchIndexerDataSourceConnection dataSource = new SearchIndexerDataSourceConnection("dataSource",
SearchIndexerDataSourceType.AZURE_BLOB, "{connectionString}",
new SearchIndexerDataContainer("container"));
Response<SearchIndexerDataSourceConnection> dataSourceFromService =
SEARCH_INDEXER_CLIENT.createDataSourceConnectionWithResponse(dataSource, new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s. The data source name is %s.%n",
dataSourceFromService.getStatusCode(), dataSourceFromService.getValue().getName());
Parameters:
Returns:
createIndexer
public SearchIndexer createIndexer(SearchIndexer indexer)
Creates a new Azure AI Search indexer.
Code Sample
Create search indexer named "searchIndexer".
SearchIndexer searchIndexer = new SearchIndexer("searchIndexer", "dataSource",
"searchIndex");
SearchIndexer indexerFromService = SEARCH_INDEXER_CLIENT.createIndexer(searchIndexer);
System.out.printf("The indexer name is %s. The ETag of indexer is %s.%n", indexerFromService.getName(),
indexerFromService.getETag());
Parameters:
Returns:
createIndexerWithResponse
public Response
Creates a new Azure AI Search indexer.
Code Sample
Create search indexer named "searchIndexer".
SearchIndexer searchIndexer = new SearchIndexer("searchIndexer", "dataSource",
"searchIndex");
Response<SearchIndexer> indexerFromServiceResponse = SEARCH_INDEXER_CLIENT.createIndexerWithResponse(
searchIndexer, new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s. The indexer name is %s.%n",
indexerFromServiceResponse.getStatusCode(), indexerFromServiceResponse.getValue().getName());
Parameters:
Returns:
createOrUpdateDataSourceConnection
public SearchIndexerDataSourceConnection createOrUpdateDataSourceConnection(SearchIndexerDataSourceConnection dataSourceConnection)
Creates a new Azure AI Search data source or updates a data source if it already exists
Code Sample
Create or update search indexer data source connection named "dataSource".
SearchIndexerDataSourceConnection dataSource = SEARCH_INDEXER_CLIENT.getDataSourceConnection("dataSource");
dataSource.setContainer(new SearchIndexerDataContainer("updatecontainer"));
SearchIndexerDataSourceConnection updateDataSource = SEARCH_INDEXER_CLIENT
.createOrUpdateDataSourceConnection(dataSource);
System.out.printf("The dataSource name is %s. The container name of dataSource is %s.%n",
updateDataSource.getName(), updateDataSource.getContainer().getName());
Parameters:
Returns:
createOrUpdateDataSourceConnectionWithResponse
public Response
Creates a new Azure AI Search data source or updates a data source if it already exists.
Code Sample
Create or update search indexer data source connection named "dataSource".
SearchIndexerDataSourceConnection dataSource = SEARCH_INDEXER_CLIENT.getDataSourceConnection("dataSource");
dataSource.setContainer(new SearchIndexerDataContainer("updatecontainer"));
Response<SearchIndexerDataSourceConnection> updateDataSource = SEARCH_INDEXER_CLIENT
.createOrUpdateDataSourceConnectionWithResponse(dataSource, true, new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s.%nThe dataSource name is %s. "
+ "The container name of dataSource is %s.%n", updateDataSource.getStatusCode(),
updateDataSource.getValue().getName(), updateDataSource.getValue().getContainer().getName());
Parameters:
true
to update if the dataSourceConnection
is the same as the current
service value. false
to always update existing value.
Returns:
createOrUpdateIndexer
public SearchIndexer createOrUpdateIndexer(SearchIndexer indexer)
Creates a new Azure AI Search indexer or updates an indexer if it already exists.
Code Sample
Create or update search indexer named "searchIndexer".
SearchIndexer searchIndexerFromService = SEARCH_INDEXER_CLIENT.getIndexer("searchIndexer");
searchIndexerFromService.setFieldMappings(Collections.singletonList(
new FieldMapping("hotelName").setTargetFieldName("HotelName")));
SearchIndexer updateIndexer = SEARCH_INDEXER_CLIENT.createOrUpdateIndexer(searchIndexerFromService);
System.out.printf("The indexer name is %s. The target field name of indexer is %s.%n",
updateIndexer.getName(), updateIndexer.getFieldMappings().get(0).getTargetFieldName());
Parameters:
Returns:
createOrUpdateIndexerWithResponse
public Response
Creates a new Azure AI Search indexer or updates an indexer if it already exists.
Code Sample
Create or update search indexer named "searchIndexer".
SearchIndexer searchIndexerFromService = SEARCH_INDEXER_CLIENT.getIndexer("searchIndexer");
searchIndexerFromService.setFieldMappings(Collections.singletonList(
new FieldMapping("hotelName").setTargetFieldName("HotelName")));
Response<SearchIndexer> indexerFromService = SEARCH_INDEXER_CLIENT.createOrUpdateIndexerWithResponse(
searchIndexerFromService, true, new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s.%nThe indexer name is %s. "
+ "The target field name of indexer is %s.%n", indexerFromService.getStatusCode(),
indexerFromService.getValue().getName(),
indexerFromService.getValue().getFieldMappings().get(0).getTargetFieldName());
Parameters:
true
to update if the indexer
is the same as the current service value.
false
to always update existing value.
Returns:
createOrUpdateSkillset
public SearchIndexerSkillset createOrUpdateSkillset(SearchIndexerSkillset skillset)
Creates a new Azure AI Search skillset or updates a skillset if it already exists.
Code Sample
Create or update search indexer skillset "searchIndexerSkillset".
SearchIndexerSkillset indexerSkillset = SEARCH_INDEXER_CLIENT.getSkillset("searchIndexerSkillset");
indexerSkillset.setDescription("This is new description!");
SearchIndexerSkillset updateSkillset = SEARCH_INDEXER_CLIENT.createOrUpdateSkillset(indexerSkillset);
System.out.printf("The indexer skillset name is %s. The description of indexer skillset is %s.%n",
updateSkillset.getName(), updateSkillset.getDescription());
Parameters:
Returns:
createOrUpdateSkillsetWithResponse
public Response
Creates a new Azure AI Search skillset or updates a skillset if it already exists.
Code Sample
Create or update search indexer skillset "searchIndexerSkillset".
SearchIndexerSkillset indexerSkillset = SEARCH_INDEXER_CLIENT.getSkillset("searchIndexerSkillset");
indexerSkillset.setDescription("This is new description!");
Response<SearchIndexerSkillset> updateSkillsetResponse = SEARCH_INDEXER_CLIENT.createOrUpdateSkillsetWithResponse(
indexerSkillset, true, new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s.%nThe indexer skillset name is %s. "
+ "The description of indexer skillset is %s.%n", updateSkillsetResponse.getStatusCode(),
updateSkillsetResponse.getValue().getName(),
updateSkillsetResponse.getValue().getDescription());
Parameters:
true
to update if the skillset
is the same as the current service value.
false
to always update existing value.
Returns:
createSkillset
public SearchIndexerSkillset createSkillset(SearchIndexerSkillset skillset)
Creates a new skillset in an Azure AI Search service.
Code Sample
Create search indexer skillset "searchIndexerSkillset".
List<InputFieldMappingEntry> inputs = Collections.singletonList(
new InputFieldMappingEntry("image")
.setSource("/document/normalized_images/*")
);
List<OutputFieldMappingEntry> outputs = Arrays.asList(
new OutputFieldMappingEntry("text")
.setTargetName("mytext"),
new OutputFieldMappingEntry("layoutText")
.setTargetName("myLayoutText")
);
SearchIndexerSkillset searchIndexerSkillset = new SearchIndexerSkillset("searchIndexerSkillset",
Collections.singletonList(new OcrSkill(inputs, outputs)
.setShouldDetectOrientation(true)
.setDefaultLanguageCode(null)
.setName("myocr")
.setDescription("Extracts text (plain and structured) from image.")
.setContext("/document/normalized_images/*")));
SearchIndexerSkillset skillset = SEARCH_INDEXER_CLIENT.createSkillset(searchIndexerSkillset);
System.out.printf("The indexer skillset name is %s. The ETag of indexer skillset is %s.%n",
skillset.getName(), skillset.getETag());
Parameters:
Returns:
createSkillsetWithResponse
public Response
Creates a new skillset in an Azure AI Search service.
Code Sample
Create search indexer skillset "searchIndexerSkillset".
List<InputFieldMappingEntry> inputs = Collections.singletonList(
new InputFieldMappingEntry("image")
.setSource("/document/normalized_images/*")
);
List<OutputFieldMappingEntry> outputs = Arrays.asList(
new OutputFieldMappingEntry("text")
.setTargetName("mytext"),
new OutputFieldMappingEntry("layoutText")
.setTargetName("myLayoutText")
);
SearchIndexerSkillset searchIndexerSkillset = new SearchIndexerSkillset("searchIndexerSkillset",
Collections.singletonList(new OcrSkill(inputs, outputs)
.setShouldDetectOrientation(true)
.setDefaultLanguageCode(null)
.setName("myocr")
.setDescription("Extracts text (plain and structured) from image.")
.setContext("/document/normalized_images/*")));
Response<SearchIndexerSkillset> skillsetWithResponse =
SEARCH_INDEXER_CLIENT.createSkillsetWithResponse(searchIndexerSkillset, new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s. The indexer skillset name is %s.%n",
skillsetWithResponse.getStatusCode(), skillsetWithResponse.getValue().getName());
Parameters:
Returns:
deleteDataSourceConnection
public void deleteDataSourceConnection(String dataSourceConnectionName)
Delete a DataSource
Code Sample
Delete all search indexer data source connection named "dataSource".
SEARCH_INDEXER_CLIENT.deleteDataSourceConnection("dataSource");
Parameters:
deleteDataSourceConnectionWithResponse
public Response
Delete a DataSource with Response
Code Sample
Delete all search indexer data source connection named "dataSource".
SearchIndexerDataSourceConnection dataSource =
SEARCH_INDEXER_CLIENT.getDataSourceConnection("dataSource");
Response<Void> deleteResponse = SEARCH_INDEXER_CLIENT.deleteDataSourceConnectionWithResponse(dataSource, true,
new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %d.%n", deleteResponse.getStatusCode());
Parameters:
true
to delete if the dataSourceConnection
is the same as the current
service value. false
to always delete existing value.
Returns:
deleteIndexer
public void deleteIndexer(String indexerName)
Deletes an Azure AI Search indexer.
Code Sample
Delete search indexer named "searchIndexer".
SEARCH_INDEXER_CLIENT.deleteIndexer("searchIndexer");
Parameters:
deleteIndexerWithResponse
public Response
Deletes an Azure AI Search indexer.
Code Sample
Delete search index named "searchIndexer".
SearchIndexer searchIndexer = SEARCH_INDEXER_CLIENT.getIndexer("searchIndexer");
Response<Void> deleteResponse = SEARCH_INDEXER_CLIENT.deleteIndexerWithResponse(searchIndexer, true,
new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %d.%n", deleteResponse.getStatusCode());
Parameters:
true
to delete if the indexer
is the same as the current service value.
false
to always delete existing value.
Returns:
deleteSkillset
public void deleteSkillset(String skillsetName)
Deletes a cognitive skillset in an Azure AI Search service.
Code Sample
Delete search indexer skillset "searchIndexerSkillset".
SEARCH_INDEXER_CLIENT.deleteSkillset("searchIndexerSkillset");
Parameters:
deleteSkillsetWithResponse
public Response
Deletes a cognitive skillset in an Azure AI Search service.
Code Sample
Delete search indexer skillset "searchIndexerSkillset".
SearchIndexerSkillset searchIndexerSkillset = SEARCH_INDEXER_CLIENT.getSkillset("searchIndexerSkillset");
Response<Void> deleteResponse = SEARCH_INDEXER_CLIENT.deleteSkillsetWithResponse(searchIndexerSkillset, true,
new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %d.%n", deleteResponse.getStatusCode());
Parameters:
true
to delete if the skillset
is the same as the current service value.
false
to always delete existing value.
Returns:
getDataSourceConnection
public SearchIndexerDataSourceConnection getDataSourceConnection(String dataSourceConnectionName)
Retrieves a DataSource from an Azure AI Search service.
Code Sample
Get search indexer data source connection named "dataSource".
SearchIndexerDataSourceConnection dataSource =
SEARCH_INDEXER_CLIENT.getDataSourceConnection("dataSource");
System.out.printf("The dataSource name is %s. The ETag of dataSource is %s.%n", dataSource.getName(),
dataSource.getETag());
Parameters:
Returns:
getDataSourceConnectionWithResponse
public Response
Retrieves a DataSource from an Azure AI Search service.
Code Sample
Get search indexer data source connection named "dataSource".
Response<SearchIndexerDataSourceConnection> dataSource =
SEARCH_INDEXER_CLIENT.getDataSourceConnectionWithResponse(
"dataSource", new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s. The data source name is %s.%n",
dataSource.getStatusCode(), dataSource.getValue().getName());
Parameters:
Returns:
getEndpoint
public String getEndpoint()
Gets the endpoint for the Azure AI Search service.
Returns:
getIndexer
public SearchIndexer getIndexer(String indexerName)
Retrieves an indexer definition.
Code Sample
Get search indexer with name "searchIndexer".
SearchIndexer indexerFromService =
SEARCH_INDEXER_CLIENT.getIndexer("searchIndexer");
System.out.printf("The indexer name is %s. The ETag of indexer is %s.%n", indexerFromService.getName(),
indexerFromService.getETag());
Parameters:
Returns:
getIndexerStatus
public SearchIndexerStatus getIndexerStatus(String indexerName)
Returns the current status and execution history of an indexer.
Code Sample
Get search indexer status.
SearchIndexerStatus indexerStatus = SEARCH_INDEXER_CLIENT.getIndexerStatus("searchIndexer");
System.out.printf("The indexer status is %s.%n", indexerStatus.getStatus());
Parameters:
Returns:
getIndexerStatusWithResponse
public Response
Returns the current status and execution history of an indexer.
Code Sample
Get search indexer status.
Response<SearchIndexerStatus> response = SEARCH_INDEXER_CLIENT.getIndexerStatusWithResponse("searchIndexer",
new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s.%nThe indexer status is %s.%n",
response.getStatusCode(), response.getValue().getStatus());
Parameters:
Returns:
getIndexerWithResponse
public Response
Retrieves an indexer definition.
Code Sample
Get search indexer with name "searchIndexer".
Response<SearchIndexer> indexerFromServiceResponse = SEARCH_INDEXER_CLIENT.getIndexerWithResponse(
"searchIndexer", new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s. The indexer name is %s.%n",
indexerFromServiceResponse.getStatusCode(), indexerFromServiceResponse.getValue().getName());
Parameters:
Returns:
getSkillset
public SearchIndexerSkillset getSkillset(String skillsetName)
Retrieves a skillset definition.
Code Sample
Get search indexer skillset "searchIndexerSkillset".
SearchIndexerSkillset indexerSkillset =
SEARCH_INDEXER_CLIENT.getSkillset("searchIndexerSkillset");
System.out.printf("The indexer skillset name is %s. The ETag of indexer skillset is %s.%n",
indexerSkillset.getName(), indexerSkillset.getETag());
Parameters:
Returns:
getSkillsetWithResponse
public Response
Retrieves a skillset definition.
Code Sample
Get search indexer skillset "searchIndexerSkillset".
Response<SearchIndexerSkillset> skillsetWithResponse = SEARCH_INDEXER_CLIENT.getSkillsetWithResponse(
"searchIndexerSkillset", new Context(KEY_1, VALUE_1));
System.out.printf("The status code of the response is %s. The indexer skillset name is %s.%n",
skillsetWithResponse.getStatusCode(), skillsetWithResponse.getValue().getName());
Parameters:
Returns:
listDataSourceConnectionNames
public PagedIterable
List all DataSource names from an Azure AI Search service.
Code Sample
List all search indexer data source connection names.
PagedIterable<String> dataSources = SEARCH_INDEXER_CLIENT.listDataSourceConnectionNames();
for (String dataSourceName: dataSources) {
System.out.printf("The dataSource name is %s.%n", dataSourceName);
}
Returns:
listDataSourceConnectionNames
public PagedIterable
List all DataSources names from an Azure AI Search service.
Code Sample
List all search indexer data source connection names.
PagedIterable<String> dataSources = SEARCH_INDEXER_CLIENT.listDataSourceConnectionNames(new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is"
+ dataSources.iterableByPage().iterator().next().getStatusCode());
for (String dataSourceName: dataSources) {
System.out.printf("The dataSource name is %s.%n", dataSourceName);
}
Parameters:
Returns:
listDataSourceConnections
public PagedIterable
List all DataSources from an Azure AI Search service.
Code Sample
List all search indexer data source connections.
PagedIterable<SearchIndexerDataSourceConnection> dataSources = SEARCH_INDEXER_CLIENT.listDataSourceConnections();
for (SearchIndexerDataSourceConnection dataSource: dataSources) {
System.out.printf("The dataSource name is %s. The ETag of dataSource is %s.%n", dataSource.getName(),
dataSource.getETag());
}
Returns:
listDataSourceConnections
public PagedIterable
List all DataSources from an Azure AI Search service.
Code Sample
List all search indexer data source connections.
PagedIterable<SearchIndexerDataSourceConnection> dataSources =
SEARCH_INDEXER_CLIENT.listDataSourceConnections(new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is"
+ dataSources.iterableByPage().iterator().next().getStatusCode());
for (SearchIndexerDataSourceConnection dataSource: dataSources) {
System.out.printf("The dataSource name is %s. The ETag of dataSource is %s.%n",
dataSource.getName(), dataSource.getETag());
}
Parameters:
Returns:
listIndexerNames
public PagedIterable
Lists all indexers names for an Azure AI Search service.
Code Sample
List all search indexer names.
PagedIterable<String> indexers = SEARCH_INDEXER_CLIENT.listIndexerNames();
for (String indexerName: indexers) {
System.out.printf("The indexer name is %s.%n", indexerName);
}
Returns:
listIndexerNames
public PagedIterable
Lists all indexers names for an Azure AI Search service.
Code Sample
List all search indexer names.
PagedIterable<String> indexers = SEARCH_INDEXER_CLIENT.listIndexerNames(new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is"
+ indexers.iterableByPage().iterator().next().getStatusCode());
for (String indexerName: indexers) {
System.out.printf("The indexer name is %s.%n", indexerName);
}
Parameters:
Returns:
listIndexers
public PagedIterable
Lists all indexers available for an Azure AI Search service.
Code Sample
List all search indexers.
PagedIterable<SearchIndexer> indexers = SEARCH_INDEXER_CLIENT.listIndexers();
for (SearchIndexer indexer: indexers) {
System.out.printf("The indexer name is %s. The ETag of indexer is %s.%n", indexer.getName(),
indexer.getETag());
}
Returns:
listIndexers
public PagedIterable
Lists all indexers available for an Azure AI Search service.
Code Sample
List all search indexers.
PagedIterable<SearchIndexer> indexers = SEARCH_INDEXER_CLIENT.listIndexers(new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is"
+ indexers.iterableByPage().iterator().next().getStatusCode());
for (SearchIndexer indexer: indexers) {
System.out.printf("The indexer name is %s. The ETag of index is %s.%n",
indexer.getName(), indexer.getETag());
}
Parameters:
Returns:
listSkillsetNames
public PagedIterable
Lists all skillset names for an Azure AI Search service.
Code Sample
List all search indexer skillset names.
PagedIterable<String> skillsetNames = SEARCH_INDEXER_CLIENT.listSkillsetNames();
for (String skillsetName: skillsetNames) {
System.out.printf("The indexer skillset name is %s.%n", skillsetName);
}
Returns:
listSkillsetNames
public PagedIterable
Lists all skillset names for an Azure AI Search service.
Code Sample
List all search indexer skillset names with response.
PagedIterable<String> skillsetNames = SEARCH_INDEXER_CLIENT.listSkillsetNames(new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is"
+ skillsetNames.iterableByPage().iterator().next().getStatusCode());
for (String skillsetName: skillsetNames) {
System.out.printf("The indexer skillset name is %s.%n", skillsetName);
}
Parameters:
Returns:
listSkillsets
public PagedIterable
Lists all skillsets available for an Azure AI Search service.
Code Sample
List all search indexer skillsets.
PagedIterable<SearchIndexerSkillset> indexerSkillsets = SEARCH_INDEXER_CLIENT.listSkillsets();
for (SearchIndexerSkillset skillset: indexerSkillsets) {
System.out.printf("The skillset name is %s. The ETag of skillset is %s.%n", skillset.getName(),
skillset.getETag());
}
Returns:
listSkillsets
public PagedIterable
Lists all skillsets available for an Azure AI Search service.
Code Sample
List all search indexer skillsets.
PagedIterable<SearchIndexerSkillset> indexerSkillsets = SEARCH_INDEXER_CLIENT
.listSkillsets(new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is"
+ indexerSkillsets.iterableByPage().iterator().next().getStatusCode());
for (SearchIndexerSkillset skillset: indexerSkillsets) {
System.out.printf("The skillset name is %s. The ETag of skillset is %s.%n",
skillset.getName(), skillset.getETag());
}
Parameters:
Returns:
resetIndexer
public void resetIndexer(String indexerName)
Resets the change tracking state associated with an indexer.
Code Sample
Reset search indexer named "searchIndexer".
SEARCH_INDEXER_CLIENT.resetIndexer("searchIndexer");
Parameters:
resetIndexerWithResponse
public Response
Resets the change tracking state associated with an indexer.
Code Sample
Reset search indexer named "searchIndexer".
Response<Void> response = SEARCH_INDEXER_CLIENT.resetIndexerWithResponse("searchIndexer",
new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is " + response.getStatusCode());
Parameters:
Returns:
runIndexer
public void runIndexer(String indexerName)
Runs an indexer on-demand.
Code Sample
Run search indexer named "searchIndexer".
SEARCH_INDEXER_CLIENT.runIndexer("searchIndexer");
Parameters:
runIndexerWithResponse
public Response
Runs an indexer on-demand.
Code Sample
Run search indexer named "searchIndexer".
Response<Void> response = SEARCH_INDEXER_CLIENT.runIndexerWithResponse("searchIndexer",
new Context(KEY_1, VALUE_1));
System.out.println("The status code of the response is " + response.getStatusCode());
Parameters:
Returns:
Applies to
Azure SDK for Java