Class SearchIndexerClient

java.lang.Object
com.azure.search.documents.indexes.SearchIndexerClient

public class SearchIndexerClient extends Object
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.
See Also:
  • Method Details

    • getEndpoint

      public String getEndpoint()
      Gets the endpoint for the Azure Cognitive Search service.
      Returns:
      the endpoint value.
    • createOrUpdateDataSourceConnection

      public SearchIndexerDataSourceConnection 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 = 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:
      dataSourceConnection - The definition of the data source to create or update.
      Returns:
      the data source that was created or updated.
    • createOrUpdateDataSourceConnectionWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerDataSourceConnection> createOrUpdateDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSourceConnection, boolean onlyIfUnchanged, com.azure.core.util.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 = 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:
      dataSourceConnection - the SearchIndexerDataSourceConnection to create or update
      onlyIfUnchanged - true to update if the dataSourceConnection is the same as the current service value. false to always update existing value.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing data source that was created or updated.
    • createOrUpdateDataSourceConnectionWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerDataSourceConnection> createOrUpdateDataSourceConnectionWithResponse(CreateOrUpdateDataSourceConnectionOptions options, com.azure.core.util.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 = SEARCH_INDEXER_CLIENT.getDataSourceConnection("dataSource");
       dataSource.setContainer(new SearchIndexerDataContainer("updatecontainer"));
       CreateOrUpdateDataSourceConnectionOptions options = new CreateOrUpdateDataSourceConnectionOptions(dataSource)
           .setOnlyIfUnchanged(true)
           .setCacheResetRequirementsIgnored(true);
      
       Response<SearchIndexerDataSourceConnection> updateDataSource = SEARCH_INDEXER_CLIENT
           .createOrUpdateDataSourceConnectionWithResponse(options, 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:
      options - The options used to create or update the data source connection.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a data source response.
      Throws:
      NullPointerException - If options is null.
    • createDataSourceConnection

      public SearchIndexerDataSourceConnection createDataSourceConnection(SearchIndexerDataSourceConnection dataSourceConnection)
      Creates a new Azure Cognitive 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:
      dataSourceConnection - The definition of the data source to create
      Returns:
      the data source that was created.
    • createDataSourceConnectionWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerDataSourceConnection> createDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSourceConnection, com.azure.core.util.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 =
           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:
      dataSourceConnection - the definition of the data source to create doesn't match specified values
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing data source that was created.
    • getDataSourceConnection

      public SearchIndexerDataSourceConnection getDataSourceConnection(String dataSourceConnectionName)
      Retrieves a DataSource from an Azure Cognitive 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:
      dataSourceConnectionName - the name of the data source to retrieve
      Returns:
      the DataSource.
    • getDataSourceConnectionWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerDataSourceConnection> getDataSourceConnectionWithResponse(String dataSourceConnectionName, com.azure.core.util.Context context)
      Retrieves a DataSource from an Azure Cognitive 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:
      dataSourceConnectionName - the name of the data source to retrieve
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing the DataSource.
    • listDataSourceConnections

      public com.azure.core.http.rest.PagedIterable<SearchIndexerDataSourceConnection> listDataSourceConnections()
      List all DataSources from an Azure Cognitive 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:
      a list of DataSources
    • listDataSourceConnections

      public com.azure.core.http.rest.PagedIterable<SearchIndexerDataSourceConnection> listDataSourceConnections(com.azure.core.util.Context context)
      List all DataSources from an Azure Cognitive 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:
      context - Additional context that is passed through the HTTP pipeline during the service call.
      Returns:
      a response containing the list of DataSources.
    • listDataSourceConnectionNames

      public com.azure.core.http.rest.PagedIterable<String> listDataSourceConnectionNames()
      List all DataSource names from an Azure Cognitive 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:
      a list of DataSources names
    • listDataSourceConnectionNames

      public com.azure.core.http.rest.PagedIterable<String> listDataSourceConnectionNames(com.azure.core.util.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 = 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:
      context - Additional context that is passed through the HTTP pipeline during the service call.
      Returns:
      a response containing the list of DataSource names.
    • 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:
      dataSourceConnectionName - the name of the data source to be deleted
    • deleteDataSourceConnectionWithResponse

      public com.azure.core.http.rest.Response<Void> deleteDataSourceConnectionWithResponse(SearchIndexerDataSourceConnection dataSourceConnection, boolean onlyIfUnchanged, com.azure.core.util.Context context)
      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:
      dataSourceConnection - the SearchIndexerDataSourceConnection to be deleted.
      onlyIfUnchanged - true to delete if the dataSourceConnection is the same as the current service value. false to always delete existing value.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      an empty response
    • createIndexer

      public SearchIndexer 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 = 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:
      indexer - definition of the indexer to create.
      Returns:
      the created Indexer.
    • createIndexerWithResponse

      public com.azure.core.http.rest.Response<SearchIndexer> createIndexerWithResponse(SearchIndexer indexer, com.azure.core.util.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 = 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:
      indexer - definition of the indexer to create
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing the created Indexer.
    • createOrUpdateIndexer

      public SearchIndexer 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 = 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:
      indexer - The definition of the indexer to create or update.
      Returns:
      a response containing the created Indexer.
    • createOrUpdateIndexerWithResponse

      public com.azure.core.http.rest.Response<SearchIndexer> createOrUpdateIndexerWithResponse(SearchIndexer indexer, boolean onlyIfUnchanged, com.azure.core.util.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 = 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:
      indexer - The SearchIndexer to create or update.
      onlyIfUnchanged - true to update if the indexer is the same as the current service value. false to always update existing value.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      A response object containing the Indexer.
    • createOrUpdateIndexerWithResponse

      public com.azure.core.http.rest.Response<SearchIndexer> createOrUpdateIndexerWithResponse(CreateOrUpdateIndexerOptions options, com.azure.core.util.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 = SEARCH_INDEXER_CLIENT.getIndexer("searchIndexer");
       searchIndexerFromService.setFieldMappings(Collections.singletonList(
           new FieldMapping("hotelName").setTargetFieldName("HotelName")));
       CreateOrUpdateIndexerOptions options = new CreateOrUpdateIndexerOptions(searchIndexerFromService)
           .setOnlyIfUnchanged(true)
           .setCacheReprocessingChangeDetectionDisabled(false)
           .setCacheResetRequirementsIgnored(true);
       Response<SearchIndexer> indexerFromService = SEARCH_INDEXER_CLIENT.createOrUpdateIndexerWithResponse(
           options, 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:
      options - The options used to create or update the indexer.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      A response object containing the Indexer.
      Throws:
      NullPointerException - If options is null.
    • listIndexers

      public com.azure.core.http.rest.PagedIterable<SearchIndexer> listIndexers()
      Lists all indexers available for an Azure Cognitive 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:
      all Indexers from the Search service.
    • listIndexers

      public com.azure.core.http.rest.PagedIterable<SearchIndexer> listIndexers(com.azure.core.util.Context context)
      Lists all indexers available for an Azure Cognitive 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:
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      all Indexers from the Search service.
    • listIndexerNames

      public com.azure.core.http.rest.PagedIterable<String> listIndexerNames()
      Lists all indexers names for an Azure Cognitive 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:
      all Indexer names from the Search service .
    • listIndexerNames

      public com.azure.core.http.rest.PagedIterable<String> listIndexerNames(com.azure.core.util.Context context)
      Lists all indexers names for an Azure Cognitive 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:
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      all Indexer names from the Search service.
    • 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:
      indexerName - the name of the indexer to retrieve
      Returns:
      the indexer.
    • getIndexerWithResponse

      public com.azure.core.http.rest.Response<SearchIndexer> getIndexerWithResponse(String indexerName, com.azure.core.util.Context context)
      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:
      indexerName - the name of the indexer to retrieve
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing the indexer.
    • deleteIndexer

      public void deleteIndexer(String indexerName)
      Deletes an Azure Cognitive Search indexer.

      Code Sample

      Delete search indexer named "searchIndexer".

       SEARCH_INDEXER_CLIENT.deleteIndexer("searchIndexer");
       
      Parameters:
      indexerName - the name of the indexer to delete
    • deleteIndexerWithResponse

      public com.azure.core.http.rest.Response<Void> deleteIndexerWithResponse(SearchIndexer indexer, boolean onlyIfUnchanged, com.azure.core.util.Context context)
      Deletes an Azure Cognitive 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:
      indexer - the search SearchIndexer
      onlyIfUnchanged - true to delete if the indexer is the same as the current service value. false to always delete existing value.
      context - the context
      Returns:
      a response signalling completion.
    • 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:
      indexerName - the name of the indexer to reset
    • resetIndexerWithResponse

      public com.azure.core.http.rest.Response<Void> resetIndexerWithResponse(String indexerName, com.azure.core.util.Context context)
      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:
      indexerName - the name of the indexer to reset
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response signalling completion.
    • runIndexer

      public void runIndexer(String indexerName)
      Runs an indexer on-demand.

      Code Sample

      Run search indexer named "searchIndexer".

       SEARCH_INDEXER_CLIENT.runIndexer("searchIndexer");
       
      Parameters:
      indexerName - the name of the indexer to run
    • runIndexerWithResponse

      public com.azure.core.http.rest.Response<Void> runIndexerWithResponse(String indexerName, com.azure.core.util.Context context)
      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:
      indexerName - the name of the indexer to run
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response signalling completion.
    • 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:
      indexerName - the name of the indexer for which to retrieve status
      Returns:
      a response with the indexer execution info.
    • getIndexerStatusWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerStatus> getIndexerStatusWithResponse(String indexerName, com.azure.core.util.Context context)
      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:
      indexerName - the name of the indexer for which to retrieve status
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response with the indexer execution info.
    • resetDocuments

      public void resetDocuments(String indexerName, Boolean overwrite, List<String> documentKeys, List<String> datasourceDocumentIds)
      Resets specific documents in the datasource to be selectively re-ingested by the indexer.
       // Reset the documents with keys 1234 and 4321.
       SEARCH_INDEXER_CLIENT.resetDocuments("searchIndexer", false, Arrays.asList("1234", "4321"), null);
      
       // Clear the previous documents to be reset and replace them with documents 1235 and 5231.
       SEARCH_INDEXER_CLIENT.resetDocuments("searchIndexer", true, Arrays.asList("1235", "5321"), null);
       
      Parameters:
      indexerName - The name of the indexer to reset documents for.
      overwrite - If false, keys or IDs will be appended to existing ones. If true, only the keys or IDs in this payload will be queued to be re-ingested.
      documentKeys - Document keys to be reset.
      datasourceDocumentIds - Datasource document identifiers to be reset.
    • resetDocumentsWithResponse

      public com.azure.core.http.rest.Response<Void> resetDocumentsWithResponse(SearchIndexer indexer, Boolean overwrite, List<String> documentKeys, List<String> datasourceDocumentIds, com.azure.core.util.Context context)
      Resets specific documents in the datasource to be selectively re-ingested by the indexer.
       SearchIndexer searchIndexer = SEARCH_INDEXER_CLIENT.getIndexer("searchIndexer");
      
       // Reset the documents with keys 1234 and 4321.
       Response<Void> resetDocsResult = SEARCH_INDEXER_CLIENT.resetDocumentsWithResponse(searchIndexer, false,
           Arrays.asList("1234", "4321"), null, new Context(KEY_1, VALUE_1));
       System.out.printf("Requesting documents to be reset completed with status code %d.%n",
           resetDocsResult.getStatusCode());
      
       // Clear the previous documents to be reset and replace them with documents 1235 and 5231.
       resetDocsResult = SEARCH_INDEXER_CLIENT.resetDocumentsWithResponse(searchIndexer, true,
           Arrays.asList("1235", "5321"), null, new Context(KEY_1, VALUE_1));
       System.out.printf("Overwriting the documents to be reset completed with status code %d.%n",
           resetDocsResult.getStatusCode());
       
      Parameters:
      indexer - The indexer to reset documents for.
      overwrite - If false, keys or IDs will be appended to existing ones. If true, only the keys or IDs in this payload will be queued to be re-ingested.
      documentKeys - Document keys to be reset.
      datasourceDocumentIds - Datasource document identifiers to be reset.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      A response signalling completion.
      Throws:
      NullPointerException - If indexer is null.
    • createSkillset

      public SearchIndexerSkillset 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 = 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:
      skillset - definition of the skillset containing one or more cognitive skills
      Returns:
      the created SearchIndexerSkillset.
    • createSkillsetWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerSkillset> createSkillsetWithResponse(SearchIndexerSkillset skillset, com.azure.core.util.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 =
           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:
      skillset - definition of the skillset containing one or more cognitive skills
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing the created SearchIndexerSkillset.
    • 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:
      skillsetName - the name of the skillset to retrieve
      Returns:
      the SearchIndexerSkillset.
    • getSkillsetWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerSkillset> getSkillsetWithResponse(String skillsetName, com.azure.core.util.Context context)
      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:
      skillsetName - the name of the skillset to retrieve
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing the SearchIndexerSkillset.
    • listSkillsets

      public com.azure.core.http.rest.PagedIterable<SearchIndexerSkillset> listSkillsets()
      Lists all skillsets available for an Azure Cognitive 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:
      the list of skillsets.
    • listSkillsets

      public com.azure.core.http.rest.PagedIterable<SearchIndexerSkillset> listSkillsets(com.azure.core.util.Context context)
      Lists all skillsets available for an Azure Cognitive 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:
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      the list of skillsets.
    • listSkillsetNames

      public com.azure.core.http.rest.PagedIterable<String> listSkillsetNames()
      Lists all skillset names for an Azure Cognitive 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:
      the list of skillset names.
    • listSkillsetNames

      public com.azure.core.http.rest.PagedIterable<String> listSkillsetNames(com.azure.core.util.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 = 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:
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      the list of skillset names.
    • createOrUpdateSkillset

      public SearchIndexerSkillset 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 = 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:
      skillset - the SearchIndexerSkillset to create or update.
      Returns:
      the skillset that was created or updated.
    • createOrUpdateSkillsetWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerSkillset> createOrUpdateSkillsetWithResponse(SearchIndexerSkillset skillset, boolean onlyIfUnchanged, com.azure.core.util.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 = 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:
      skillset - the SearchIndexerSkillset to create or update.
      onlyIfUnchanged - true to update if the skillset is the same as the current service value. false to always update existing value.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing the skillset that was created or updated.
    • createOrUpdateSkillsetWithResponse

      public com.azure.core.http.rest.Response<SearchIndexerSkillset> createOrUpdateSkillsetWithResponse(CreateOrUpdateSkillsetOptions options, com.azure.core.util.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 = SEARCH_INDEXER_CLIENT.getSkillset("searchIndexerSkillset");
       indexerSkillset.setDescription("This is new description!");
       CreateOrUpdateSkillsetOptions options = new CreateOrUpdateSkillsetOptions(indexerSkillset)
           .setOnlyIfUnchanged(true)
           .setCacheReprocessingChangeDetectionDisabled(false)
           .setCacheResetRequirementsIgnored(true);
       Response<SearchIndexerSkillset> updateSkillsetResponse = SEARCH_INDEXER_CLIENT.createOrUpdateSkillsetWithResponse(
           options, 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:
      options - The options used to create or update the skillset.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response containing the skillset that was created or updated.
      Throws:
      NullPointerException - If options is null.
    • deleteSkillset

      public void deleteSkillset(String skillsetName)
      Deletes a cognitive skillset in an Azure Cognitive Search service.

      Code Sample

      Delete search indexer skillset "searchIndexerSkillset".

       SEARCH_INDEXER_CLIENT.deleteSkillset("searchIndexerSkillset");
       
      Parameters:
      skillsetName - the name of the skillset to delete
    • deleteSkillsetWithResponse

      public com.azure.core.http.rest.Response<Void> deleteSkillsetWithResponse(SearchIndexerSkillset skillset, boolean onlyIfUnchanged, com.azure.core.util.Context context)
      Deletes a cognitive skillset in an Azure Cognitive 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:
      skillset - the SearchIndexerSkillset to delete.
      onlyIfUnchanged - true to delete if the skillset is the same as the current service value. false to always delete existing value.
      context - additional context that is passed through the HTTP pipeline during the service call
      Returns:
      a response signalling completion.
    • resetSkills

      public void resetSkills(String skillsetName, List<String> skillNames)
      Resets skills in an existing skillset in an Azure Cognitive Search service.
       // Reset the "myOcr" and "myText" skills.
       SEARCH_INDEXER_CLIENT.resetSkills("searchIndexerSkillset", Arrays.asList("myOcr", "myText"));
       
      Parameters:
      skillsetName - The name of the skillset to reset.
      skillNames - The skills to reset.
    • resetSkillsWithResponse

      public com.azure.core.http.rest.Response<Void> resetSkillsWithResponse(SearchIndexerSkillset skillset, List<String> skillNames, com.azure.core.util.Context context)
      Resets skills in an existing skillset in an Azure Cognitive Search service.
       SearchIndexerSkillset searchIndexerSkillset = SEARCH_INDEXER_CLIENT.getSkillset("searchIndexerSkillset");
      
       // Reset the "myOcr" and "myText" skills.
       Response<Void> resetSkillsResponse = SEARCH_INDEXER_CLIENT.resetSkillsWithResponse(searchIndexerSkillset,
           Arrays.asList("myOcr", "myText"), new Context(KEY_1, VALUE_1));
       System.out.printf("Resetting skills completed with status code %d.%n", resetSkillsResponse.getStatusCode());
       
      Parameters:
      skillset - The skillset to reset.
      skillNames - The skills to reset.
      context - Additional context that is passed through the HTTP pipeline during the service call.
      Returns:
      A response signalling completion.
      Throws:
      NullPointerException - If skillset is null.