Class IndexBatchException

  • All Implemented Interfaces:
    Serializable

    public final class IndexBatchException
    extends com.azure.core.exception.AzureException
    An IndexBatchException is thrown whenever Azure Cognitive Search index call was only partially successful. Users can inspect the indexingResults to determine the operation(s) that have failed.
    See Also:
    Serialized Form
    • Constructor Detail

      • IndexBatchException

        public IndexBatchException​(IndexDocumentsResult result)
        Constructs an IndexBatchException from the given IndexDocumentsResult.
        Parameters:
        result - The DocumentIndexResult returned from the service.
    • Method Detail

      • findFailedActionsToRetry

        public IndexBatchBase<SearchDocument> findFailedActionsToRetry​(IndexBatchBase<SearchDocument> originalBatch,
                                                                       String keyFieldName)
        Finds all index actions in the given batch that failed and need to be retried, and returns them in a new batch.
        Parameters:
        originalBatch - The batch that partially failed indexing.
        keyFieldName - The name of the key field from the index schema.
        Returns:
        A new batch containing all the actions from the given batch that failed and should be retried.
      • findFailedActionsToRetry

        public <T> IndexBatchBase<T> findFailedActionsToRetry​(IndexBatchBase<T> originBatch,
                                                              Function<T,​String> keySelector)
        Finds all index actions in the given batch that failed and need to be retried, and returns them in a new batch.
        Type Parameters:
        T - The given document type.
        Parameters:
        originBatch - The batch that partially failed indexing.
        keySelector - A lambda that retrieves a key value from a given document of type T.
        Returns:
        A new batch containing all the actions from the given batch that failed and should be retried.
      • getIndexingResults

        public List<IndexingResult> getIndexingResults()
        Returns:
        The indexing results returned by the service.