SearchIndexerClient Class

Definition

  • java.lang.Object
    • com.azure.search.documents.indexes.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 Cognitive Search service.

public class SearchIndexerClient

Methods

createDataSourceConnection(SearchIndexerDataSourceConnection dataSourceConnection)

Creates a new Azure Cognitive Search data source

Code Sample

Create search indexer data source connection named "dataSource".

SearchIndexerDataSourceConnection dataSource = searchIndexerClient.getDataSourceConnection("dataSource");
 dataSource.setContainer(new SearchIndexerDataContainer("updatecontainer"));

 SearchIndexerDataSourceConnection updateDataSource = searchIndexerClient.createOrUpdateDataSourceConnection(dataSource);
 System.out.printf("The dataSource name is %s. The container name of dataSource is %s.%n",
     updateDataSource.getName(), updateDataSource.getContainer().getName());
createDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSourceConnection, Context context)

Creates a new Azure Cognitive 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 =
     searchIndexerClient.createDataSourceConnectionWithResponse(dataSource, new Context(key1, value1));

 System.out.printf("The status code of the response is %s. The data source name is %s.%n",
     dataSourceFromService.getStatusCode(), dataSourceFromService.getValue().getName());
createIndexer(SearchIndexer indexer)

Creates a new Azure Cognitive Search indexer.

Code Sample

Create search indexer named "searchIndexer".

SearchIndexer searchIndexer = new SearchIndexer("searchIndexer", "dataSource",
     "searchIndex");
 SearchIndexer indexerFromService = searchIndexerClient.createIndexer(searchIndexer);
 System.out.printf("The indexer name is %s. The etag of indexer is %s.%n", indexerFromService.getName(),
     indexerFromService.getETag());
createIndexerWithResponse(SearchIndexer indexer, Context context)

Creates a new Azure Cognitive Search indexer.

Code Sample

Create search indexer named "searchIndexer".

SearchIndexer searchIndexer = new SearchIndexer("searchIndexer", "dataSource",
     "searchIndex");
 Response<SearchIndexer> indexerFromServiceResponse = searchIndexerClient.createIndexerWithResponse(
     searchIndexer, new Context(key1, value1));

 System.out.printf("The status code of the response is %s. The indexer name is %s.%n",
     indexerFromServiceResponse.getStatusCode(), indexerFromServiceResponse.getValue().getName());
createOrUpdateDataSourceConnection(SearchIndexerDataSourceConnection dataSourceConnection)

Creates a new Azure Cognitive 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 = searchIndexerClient.getDataSourceConnection("dataSource");
 dataSource.setContainer(new SearchIndexerDataContainer("updatecontainer"));

 SearchIndexerDataSourceConnection updateDataSource = searchIndexerClient.createOrUpdateDataSourceConnection(dataSource);
 System.out.printf("The dataSource name is %s. The container name of dataSource is %s.%n",
     updateDataSource.getName(), updateDataSource.getContainer().getName());
createOrUpdateDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSourceConnection, boolean onlyIfUnchanged, Context context)

Creates a new Azure Cognitive 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 = searchIndexerClient.getDataSourceConnection("dataSource");
 dataSource.setContainer(new SearchIndexerDataContainer("updatecontainer"));

 Response<SearchIndexerDataSourceConnection> updateDataSource = searchIndexerClient
     .createOrUpdateDataSourceConnectionWithResponse(dataSource, true, new Context(key1, value1));
 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());
createOrUpdateIndexer(SearchIndexer indexer)

Creates a new Azure Cognitive Search indexer or updates an indexer if it already exists.

Code Sample

Create or update search indexer named "searchIndexer".

SearchIndexer searchIndexerFromService = searchIndexerClient.getIndexer("searchIndexer");
 searchIndexerFromService.setFieldMappings(Collections.singletonList(
     new FieldMapping("hotelName").setTargetFieldName("HotelName")));
 SearchIndexer updateIndexer = searchIndexerClient.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());
createOrUpdateIndexerWithResponse(SearchIndexer indexer, boolean onlyIfUnchanged, Context context)

Creates a new Azure Cognitive Search indexer or updates an indexer if it already exists.

Code Sample

Create or update search indexer named "searchIndexer".

SearchIndexer searchIndexerFromService = searchIndexerClient.getIndexer("searchIndexer");
 searchIndexerFromService.setFieldMappings(Collections.singletonList(
     new FieldMapping("hotelName").setTargetFieldName("HotelName")));
 Response<SearchIndexer> indexerFromService = searchIndexerClient.createOrUpdateIndexerWithResponse(
     searchIndexerFromService, true, new Context(key1, value1));
 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());
createOrUpdateSkillset(SearchIndexerSkillset skillset)

Creates a new Azure Cognitive Search skillset or updates a skillset if it already exists.

Code Sample

Create or update search indexer skillset "searchIndexerSkillset".

SearchIndexerSkillset indexerSkillset = searchIndexerClient.getSkillset("searchIndexerSkilset");
 indexerSkillset.setDescription("This is new description!");
 SearchIndexerSkillset updateSkillset = searchIndexerClient.createOrUpdateSkillset(indexerSkillset);
 System.out.printf("The indexer skillset name is %s. The description of indexer skillset is %s.%n",
     updateSkillset.getName(), updateSkillset.getDescription());
createOrUpdateSkillsetWithResponse(SearchIndexerSkillset skillset, boolean onlyIfUnchanged, Context context)

Creates a new Azure Cognitive Search skillset or updates a skillset if it already exists.

Code Sample

Create or update search indexer skillset "searchIndexerSkillset".

SearchIndexerSkillset indexerSkillset = searchIndexerClient.getSkillset("searchIndexerSkilset");
 indexerSkillset.setDescription("This is new description!");
 Response<SearchIndexerSkillset> updateSkillsetResponse = searchIndexerClient.createOrUpdateSkillsetWithResponse(
     indexerSkillset, true, new Context(key1, value1));
 System.out.printf("The status code of the response is %s.%nThe indexer skillset name is %s. "
         + "The description of indexer skilset is %s.%n", updateSkillsetResponse.getStatusCode(),
     updateSkillsetResponse.getValue().getName(),
     updateSkillsetResponse.getValue().getDescription());
createSkillset(SearchIndexerSkillset skillset)

Creates a new skillset in an Azure Cognitive 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 = searchIndexerClient.createSkillset(searchIndexerSkillset);
 System.out.printf("The indexer skillset name is %s. The etag of indexer skillset is %s.%n",
     skillset.getName(), skillset.getETag());
createSkillsetWithResponse(SearchIndexerSkillset skillset, Context context)

Creates a new skillset in an Azure Cognitive 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 =
     searchIndexerClient.createSkillsetWithResponse(searchIndexerSkillset, new Context(key1, value1));
 System.out.printf("The status code of the response is %s. The indexer skillset name is %s.%n",
     skillsetWithResponse.getStatusCode(), skillsetWithResponse.getValue().getName());
deleteDataSourceConnection(String dataSourceConnectionName)

Delete a DataSource

Code Sample

Delete all search indexer data source connection named "dataSource".

searchIndexerClient.deleteDataSourceConnection("dataSource");
deleteDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSourceConnection, boolean onlyIfUnchanged, Context context)

Delete a DataSource with Response

Code Sample

Delete all search indexer data source connection named "dataSource".

SearchIndexerDataSourceConnection dataSource =
     searchIndexerClient.getDataSourceConnection("dataSource");
 Response<Void> deleteResponse = searchIndexerClient.deleteDataSourceConnectionWithResponse(dataSource, true,
     new Context(key1, value1));
 System.out.printf("The status code of the response is %d.%n", deleteResponse.getStatusCode());
deleteIndexer(String indexerName)

Deletes an Azure Cognitive Search indexer.

Code Sample

Delete search indexer named "searchIndexer".

searchIndexerClient.deleteIndexer("searchIndexer");
deleteIndexerWithResponse(SearchIndexer indexer, boolean onlyIfUnchanged, Context context)

Deletes an Azure Cognitive Search indexer.

Code Sample

Delete search indexe named "searchIndexer".

SearchIndexer searchIndexer = searchIndexerClient.getIndexer("searchIndexer");
 Response<Void> deleteResponse = searchIndexerClient.deleteIndexerWithResponse(searchIndexer, true,
     new Context(key1, value1));
 System.out.printf("The status code of the response is %d.%n", deleteResponse.getStatusCode());
deleteSkillset(String skillsetName)

Deletes a cognitive skillset in an Azure Cognitive Search service.

Code Sample

Delete search indexer skillset "searchIndexerSkillset".

searchIndexerClient.deleteSkillset("searchIndexerSkillset");
deleteSkillsetWithResponse(SearchIndexerSkillset skillset, boolean onlyIfUnchanged, Context context)

Deletes a cognitive skillset in an Azure Cognitive Search service.

Code Sample

Delete search indexer skillset "searchIndexerSkillset".

SearchIndexerSkillset searchIndexerSkilset = searchIndexerClient.getSkillset("searchIndexerSkilset");
 Response<Void> deleteResponse = searchIndexerClient.deleteSkillsetWithResponse(searchIndexerSkilset, true,
     new Context(key1, value1));
 System.out.printf("The status code of the response is %d.%n", deleteResponse.getStatusCode());
getDataSourceConnection(String dataSourceConnectionName)

Retrieves a DataSource from an Azure Cognitive Search service.

Code Sample

Get search indexer data source connection named "dataSource".

SearchIndexerDataSourceConnection dataSource =
     searchIndexerClient.getDataSourceConnection("dataSource");
 System.out.printf("The dataSource name is %s. The etag of dataSource is %s.%n", dataSource.getName(),
     dataSource.getETag());
getDataSourceConnectionWithResponse(String dataSourceConnectionName, Context context)

Retrieves a DataSource from an Azure Cognitive Search service.

Code Sample

Get search indexer data source connection named "dataSource".

Response<SearchIndexerDataSourceConnection> dataSource =
     searchIndexerClient.getDataSourceConnectionWithResponse(
         "dataSource", new Context(key1, value1));

 System.out.printf("The status code of the response is %s. The data source name is %s.%n",
     dataSource.getStatusCode(), dataSource.getValue().getName());
getEndpoint()

Gets the endpoint for the Azure Cognitive Search service.

getIndexer(String indexerName)

Retrieves an indexer definition.

Code Sample

Get search indexer with name "searchIndexer".

SearchIndexer indexerFromService =
     searchIndexerClient.getIndexer("searchIndexer");
 System.out.printf("The indexer name is %s. The etag of indexer is %s.%n", indexerFromService.getName(),
     indexerFromService.getETag());
getIndexerStatus(String indexerName)

Returns the current status and execution history of an indexer.

Code Sample

Get search indexer status.

SearchIndexerStatus indexerStatus = searchIndexerClient.getIndexerStatus("searchIndexer");
 System.out.printf("The indexer status is %s.%n", indexerStatus.getStatus());
getIndexerStatusWithResponse(String indexerName, Context context)

Returns the current status and execution history of an indexer.

Code Sample

Get search indexer status.

Response<SearchIndexerStatus> response = searchIndexerClient.getIndexerStatusWithResponse("searchIndexer",
     new Context(key1, value1));
 System.out.printf("The status code of the response is %s.%nThe indexer status is %s.%n",
     response.getStatusCode(), response.getValue().getStatus());
getIndexerWithResponse(String indexerName, Context context)

Retrieves an indexer definition.

Code Sample

Get search indexer with name "searchIndexer".

Response<SearchIndexer> indexerFromServiceResponse = searchIndexerClient.getIndexerWithResponse(
     "searchIndexer", new Context(key1, value1));

 System.out.printf("The status code of the response is %s. The indexer name is %s.%n",
     indexerFromServiceResponse.getStatusCode(), indexerFromServiceResponse.getValue().getName());
getSkillset(String skillsetName)

Retrieves a skillset definition.

Code Sample

Get search indexer skillset "searchIndexerSkillset".

SearchIndexerSkillset indexerSkillset =
     searchIndexerClient.getSkillset("searchIndexerSkillset");
 System.out.printf("The indexer skillset name is %s. The etag of indexer skillset is %s.%n",
     indexerSkillset.getName(), indexerSkillset.getETag());
getSkillsetWithResponse(String skillsetName, Context context)

Retrieves a skillset definition.

Code Sample

Get search indexer skillset "searchIndexerSkillset".

Response<SearchIndexerSkillset> skillsetWithResponse = searchIndexerClient.getSkillsetWithResponse(
     "searchIndexerSkillset", new Context(key1, value1));

 System.out.printf("The status code of the response is %s. The indexer skillset name is %s.%n",
     skillsetWithResponse.getStatusCode(), skillsetWithResponse.getValue().getName());
listDataSourceConnectionNames()

List all DataSource names from an Azure Cognitive Search service.

Code Sample

List all search indexer data source connection names.

PagedIterable<String> dataSources = searchIndexerClient.listDataSourceConnectionNames();
 for (String dataSourceName: dataSources) {
     System.out.printf("The dataSource name is %s.%n", dataSourceName);
 }
listDataSourceConnectionNames(Context context)

List all DataSources names from an Azure Cognitive Search service.

Code Sample

List all search indexer data source connection names.

PagedIterable<String> dataSources = searchIndexerClient.listDataSourceConnectionNames(new Context(key1, value1));
 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);
 }
listDataSourceConnections()

List all DataSources from an Azure Cognitive Search service.

Code Sample

List all search indexer data source connections.

PagedIterable<SearchIndexerDataSourceConnection> dataSources = searchIndexerClient.listDataSourceConnections();
 for (SearchIndexerDataSourceConnection dataSource: dataSources) {
     System.out.printf("The dataSource name is %s. The etag of dataSource is %s.%n", dataSource.getName(),
         dataSource.getETag());
 }
listDataSourceConnections(Context context)

List all DataSources from an Azure Cognitive Search service.

Code Sample

List all search indexer data source connections.

PagedIterable<SearchIndexerDataSourceConnection> dataSources =
     searchIndexerClient.listDataSourceConnections(new Context(key1, value1));

 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());
 }
listIndexerNames()

Lists all indexers names for an Azure Cognitive Search service.

Code Sample

List all search indexer names.

PagedIterable<String> indexers = searchIndexerClient.listIndexerNames();
 for (String indexerName: indexers) {
     System.out.printf("The indexer name is %s.%n", indexerName);
 }
listIndexerNames(Context context)

Lists all indexers names for an Azure Cognitive Search service.

Code Sample

List all search indexer names.

PagedIterable<String> indexers = searchIndexerClient.listIndexerNames(new Context(key1, value1));
 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);
 }
listIndexers()

Lists all indexers available for an Azure Cognitive Search service.

Code Sample

List all search indexers.

PagedIterable<SearchIndexer> indexers = searchIndexerClient.listIndexers();
 for (SearchIndexer indexer: indexers) {
     System.out.printf("The indexer name is %s. The etag of indexer is %s.%n", indexer.getName(),
         indexer.getETag());
 }
listIndexers(Context context)

Lists all indexers available for an Azure Cognitive Search service.

Code Sample

List all search indexers.

PagedIterable<SearchIndexer> indexers = searchIndexerClient.listIndexers(new Context(key1, value1));
 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());
 }
listSkillsetNames()

Lists all skillset names for an Azure Cognitive Search service.

Code Sample

List all search indexer skillset names.

PagedIterable<String> skillsetNames = searchIndexerClient.listSkillsetNames();
 for (String skillsetName: skillsetNames) {
     System.out.printf("The indexer skillset name is %s.%n", skillsetName);
 }
listSkillsetNames(Context context)

Lists all skillset names for an Azure Cognitive Search service.

Code Sample

List all search indexer skillset names with response.

PagedIterable<String> skillsetNames = searchIndexerClient.listSkillsetNames(new Context(key1, value1));
 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);
 }
listSkillsets()

Lists all skillsets available for an Azure Cognitive Search service.

Code Sample

List all search indexer skillsets.

PagedIterable<SearchIndexerSkillset> indexerSkillsets = searchIndexerClient.listSkillsets();
 for (SearchIndexerSkillset skillset: indexerSkillsets) {
     System.out.printf("The skillset name is %s. The etag of skillset is %s.%n", skillset.getName(),
         skillset.getETag());
 }
listSkillsets(Context context)

Lists all skillsets available for an Azure Cognitive Search service.

Code Sample

List all search indexer skillsets.

PagedIterable<SearchIndexerSkillset> indexerSkillsets = searchIndexerClient.listSkillsets(new Context(key1, value1));
 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());
 }
resetIndexer(String indexerName)

Resets the change tracking state associated with an indexer.

Code Sample

Reset search indexer named "searchIndexer".

searchIndexerClient.resetIndexer("searchIndexer");
resetIndexerWithResponse(String indexerName, Context context)

Resets the change tracking state associated with an indexer.

Code Sample

Reset search indexer named "searchIndexer".

Response<Void> response = searchIndexerClient.resetIndexerWithResponse("searchIndexer",
     new Context(key1, value1));
 System.out.println("The status code of the response is " + response.getStatusCode());
runIndexer(String indexerName)

Runs an indexer on-demand.

Code Sample

Run search indexer named "searchIndexer".

searchIndexerClient.runIndexer("searchIndexer");
runIndexerWithResponse(String indexerName, Context context)

Runs an indexer on-demand.

Code Sample

Run search indexer named "searchIndexer".

Response<Void> response = searchIndexerClient.runIndexerWithResponse("searchIndexer",
     new Context(key1, value1));
 System.out.println("The status code of the response is " + response.getStatusCode());

Inherited Members

java.lang.Object.clone() java.lang.Object.equals(java.lang.Object) java.lang.Object.finalize() java.lang.Object.getClass() java.lang.Object.hashCode() java.lang.Object.notify() java.lang.Object.notifyAll() java.lang.Object.toString() java.lang.Object.wait() java.lang.Object.wait(long) java.lang.Object.wait(long,int)

Applies to