SearchIndexingBufferedSenderBuilder<T> Class

  • java.lang.Object
    • com.azure.search.documents.SearchIndexingBufferedSenderBuilder<T>

Type Parameters

T

The type of the document that the buffered sender will use.

Implements

public final class SearchIndexingBufferedSenderBuilder<T>
implements HttpTrait<SearchIndexingBufferedSenderBuilder<T>>, ConfigurationTrait<SearchIndexingBufferedSenderBuilder<T>>, TokenCredentialTrait<SearchIndexingBufferedSenderBuilder<T>>, KeyCredentialTrait<SearchIndexingBufferedSenderBuilder<T>>, EndpointTrait<SearchIndexingBufferedSenderBuilder<T>>

This class provides a fluent builder API to help aid the configuration and instantiation of SearchIndexingBufferedSender<T> and SearchIndexingBufferedAsyncSender<T>. Call buildSender() and buildAsyncSender() respectively to construct an instance of the desired sender.

Constructor Summary

Constructor Description
SearchIndexingBufferedSenderBuilder()

Creates a new instance of SearchIndexingBufferedSenderBuilder<T>.

Method Summary

Modifier and Type Method and Description
SearchIndexingBufferedSenderBuilder<T> addPolicy(HttpPipelinePolicy customPolicy)

.

SearchIndexingBufferedSenderBuilder<T> audience(SearchAudience audience)

Sets the Audience to use for authentication with Microsoft Entra ID.

SearchIndexingBufferedSenderBuilder<T> autoFlush(boolean autoFlush)

Sets the flag determining whether a buffered sender will automatically flush its document batch based on the configurations of autoFlushInterval(Duration autoFlushInterval) and initialBatchActionCount(int initialBatchActionCount).

SearchIndexingBufferedSenderBuilder<T> autoFlushInterval(Duration autoFlushInterval)

Sets the duration between a buffered sender sending documents to be indexed.

SearchIndexingBufferedAsyncSender<T> buildAsyncSender()

Creates a SearchIndexingBufferedAsyncSender<T> based on options set in the builder.

SearchIndexingBufferedSender<T> buildSender()

Creates a SearchIndexingBufferedSender<T> based on options set in the builder.

SearchIndexingBufferedSenderBuilder<T> clientOptions(ClientOptions clientOptions)

.

SearchIndexingBufferedSenderBuilder<T> configuration(Configuration configuration)

.

SearchIndexingBufferedSenderBuilder<T> credential(KeyCredential keyCredential)

.

SearchIndexingBufferedSenderBuilder<T> credential(TokenCredential tokenCredential)

.

SearchIndexingBufferedSenderBuilder<T> documentKeyRetriever(Function<Map<String,Object>,String> documentKeyRetriever)

Sets the function that retrieves the key value from a document.

SearchIndexingBufferedSenderBuilder<T> endpoint(String endpoint)

.

SearchIndexingBufferedSenderBuilder<T> httpClient(HttpClient httpClient)

.

SearchIndexingBufferedSenderBuilder<T> httpLogOptions(HttpLogOptions httpLogOptions)

.

SearchIndexingBufferedSenderBuilder<T> indexName(String indexName)

Sets the name of the index.

SearchIndexingBufferedSenderBuilder<T> initialBatchActionCount(int initialBatchActionCount)

Sets the number of documents before a buffered sender will send the batch to be indexed.

SearchIndexingBufferedSenderBuilder<T> maxRetriesPerAction(int maxRetriesPerAction)

Sets the number of times an action will retry indexing before it is considered failed.

SearchIndexingBufferedSenderBuilder<T> maxThrottlingDelay(Duration maxThrottlingDelay)

Sets the maximum duration that requests will be delayed when the service is throttling.

SearchIndexingBufferedSenderBuilder<T> onActionAdded(Consumer<OnActionAddedOptions> onActionAddedConsumer)

Callback hook for when a document indexing action has been added to a batch queued.

SearchIndexingBufferedSenderBuilder<T> onActionError(Consumer<OnActionErrorOptions> onActionErrorConsumer)

Sets the callback hook for when a document indexing action has failed to index and isn't retryable.

SearchIndexingBufferedSenderBuilder<T> onActionSent(Consumer<OnActionSentOptions> onActionSentConsumer)

Sets the callback hook for when a document indexing has been sent in a batching request.

SearchIndexingBufferedSenderBuilder<T> onActionSucceeded(Consumer<OnActionSucceededOptions> onActionSucceededConsumer)

Sets the callback hook for when a document indexing action has successfully completed indexing.

SearchIndexingBufferedSenderBuilder<T> pipeline(HttpPipeline pipeline)

.

SearchIndexingBufferedSenderBuilder<T> retryOptions(RetryOptions retryOptions)

.

SearchIndexingBufferedSenderBuilder<T> retryPolicy(RetryPolicy retryPolicy)

Sets the retry policy that will attempt to retry failed requests, if applicable.

SearchIndexingBufferedSenderBuilder<T> serializer(JsonSerializer jsonSerializer)

Custom JSON serializer that is used to handle model types that are not contained in the Azure Search Documents library.

SearchIndexingBufferedSenderBuilder<T> serviceVersion(SearchServiceVersion serviceVersion)

Sets the service version.

SearchIndexingBufferedSenderBuilder<T> throttlingDelay(Duration throttlingDelay)

Sets the initial duration that requests will be delayed when the service is throttling.

Methods inherited from java.lang.Object

Constructor Details

SearchIndexingBufferedSenderBuilder

public SearchIndexingBufferedSenderBuilder()

Creates a new instance of SearchIndexingBufferedSenderBuilder<T>.

Method Details

addPolicy

public SearchIndexingBufferedSenderBuilder<T> addPolicy(HttpPipelinePolicy customPolicy)

.

Parameters:

customPolicy

audience

public SearchIndexingBufferedSenderBuilder<T> audience(SearchAudience audience)

Sets the Audience to use for authentication with Microsoft Entra ID.

If audience is null the public cloud audience will be assumed.

Parameters:

audience - The Audience to use for authentication with Microsoft Entra ID.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

autoFlush

public SearchIndexingBufferedSenderBuilder<T> autoFlush(boolean autoFlush)

Sets the flag determining whether a buffered sender will automatically flush its document batch based on the configurations of autoFlushInterval(Duration autoFlushInterval) and initialBatchActionCount(int initialBatchActionCount).

Parameters:

autoFlush - Flag determining whether a buffered sender will automatically flush.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

autoFlushInterval

public SearchIndexingBufferedSenderBuilder<T> autoFlushInterval(Duration autoFlushInterval)

Sets the duration between a buffered sender sending documents to be indexed.

The buffered sender will reset the duration when documents are sent for indexing, either by reaching initialBatchActionCount(int initialBatchActionCount) or by a manual trigger.

If autoFlushInterval is negative or zero and autoFlush(boolean autoFlush) is enabled the buffered sender will only flush when initialBatchActionCount(int initialBatchActionCount) is met.

Parameters:

autoFlushInterval - Duration between document batches being sent for indexing.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

buildAsyncSender

public SearchIndexingBufferedAsyncSender<T> buildAsyncSender()

Creates a SearchIndexingBufferedAsyncSender<T> based on options set in the builder. Every time this is called a new instance of SearchIndexingBufferedAsyncSender<T> is created.

Returns:

A SearchIndexingBufferedAsyncSender with the options set from the builder.

buildSender

public SearchIndexingBufferedSender<T> buildSender()

Creates a SearchIndexingBufferedSender<T> based on options set in the builder. Every time this is called a new instance of SearchIndexingBufferedSender<T> is created.

Returns:

A SearchIndexingBufferedSender with the options set from the builder.

clientOptions

public SearchIndexingBufferedSenderBuilder<T> clientOptions(ClientOptions clientOptions)

.

Parameters:

clientOptions

configuration

public SearchIndexingBufferedSenderBuilder<T> configuration(Configuration configuration)

.

Parameters:

configuration

credential

public SearchIndexingBufferedSenderBuilder<T> credential(KeyCredential keyCredential)

.

Parameters:

keyCredential

credential

public SearchIndexingBufferedSenderBuilder<T> credential(TokenCredential tokenCredential)

.

Parameters:

tokenCredential

documentKeyRetriever

public SearchIndexingBufferedSenderBuilder<T> documentKeyRetriever(Function<Map<String,Object>,String> documentKeyRetriever)

Sets the function that retrieves the key value from a document.

Parameters:

documentKeyRetriever - Function that retrieves the key from an IndexAction.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

endpoint

public SearchIndexingBufferedSenderBuilder<T> endpoint(String endpoint)

.

Parameters:

endpoint

httpClient

public SearchIndexingBufferedSenderBuilder<T> httpClient(HttpClient httpClient)

.

Parameters:

httpClient

httpLogOptions

public SearchIndexingBufferedSenderBuilder<T> httpLogOptions(HttpLogOptions httpLogOptions)

.

Parameters:

httpLogOptions

indexName

public SearchIndexingBufferedSenderBuilder<T> indexName(String indexName)

Sets the name of the index.

Parameters:

indexName - the indexName value.

Returns:

the SearchIndexingBufferedSenderBuilder.

initialBatchActionCount

public SearchIndexingBufferedSenderBuilder<T> initialBatchActionCount(int initialBatchActionCount)

Sets the number of documents before a buffered sender will send the batch to be indexed.

This will only trigger a batch to be sent automatically if #autoFlushInterval is configured. Default value is 512.

Parameters:

initialBatchActionCount - The number of documents in a batch that will trigger it to be indexed.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

maxRetriesPerAction

public SearchIndexingBufferedSenderBuilder<T> maxRetriesPerAction(int maxRetriesPerAction)

Sets the number of times an action will retry indexing before it is considered failed.

Documents are only retried on retryable status codes.

Default value is 3.

Parameters:

maxRetriesPerAction - The number of times a document will retry indexing before it is considered failed.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

maxThrottlingDelay

public SearchIndexingBufferedSenderBuilder<T> maxThrottlingDelay(Duration maxThrottlingDelay)

Sets the maximum duration that requests will be delayed when the service is throttling.

If maxThrottlingDelay is less than throttlingDelay(Duration throttlingDelay) then throttlingDelay(Duration throttlingDelay) will be used as the maximum delay.

Default value is Duration.ofMinutes(1).

Parameters:

maxThrottlingDelay - The maximum duration requests will delay when the service is throttling.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

onActionAdded

public SearchIndexingBufferedSenderBuilder<T> onActionAdded(Consumer<OnActionAddedOptions> onActionAddedConsumer)

Callback hook for when a document indexing action has been added to a batch queued.

Parameters:

onActionAddedConsumer - The Consumer that is called when a document has been added to a batch queue.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

onActionError

public SearchIndexingBufferedSenderBuilder<T> onActionError(Consumer<OnActionErrorOptions> onActionErrorConsumer)

Sets the callback hook for when a document indexing action has failed to index and isn't retryable.

Parameters:

onActionErrorConsumer - The Consumer that is called when a document has failed to index and isn't retryable.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

onActionSent

public SearchIndexingBufferedSenderBuilder<T> onActionSent(Consumer<OnActionSentOptions> onActionSentConsumer)

Sets the callback hook for when a document indexing has been sent in a batching request.

Parameters:

onActionSentConsumer - The Consumer that is called when a document has been sent in a batch request.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

onActionSucceeded

public SearchIndexingBufferedSenderBuilder<T> onActionSucceeded(Consumer<OnActionSucceededOptions> onActionSucceededConsumer)

Sets the callback hook for when a document indexing action has successfully completed indexing.

Parameters:

onActionSucceededConsumer - The Consumer that is called when a document has been successfully indexing.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

pipeline

public SearchIndexingBufferedSenderBuilder<T> pipeline(HttpPipeline pipeline)

.

Parameters:

pipeline

retryOptions

public SearchIndexingBufferedSenderBuilder<T> retryOptions(RetryOptions retryOptions)

.

Parameters:

retryOptions

retryPolicy

public SearchIndexingBufferedSenderBuilder<T> retryPolicy(RetryPolicy retryPolicy)

Sets the retry policy that will attempt to retry failed requests, if applicable.

Parameters:

retryPolicy - the retryPolicy value.

Returns:

the SearchIndexingBufferedSenderBuilder.

serializer

public SearchIndexingBufferedSenderBuilder<T> serializer(JsonSerializer jsonSerializer)

Custom JSON serializer that is used to handle model types that are not contained in the Azure Search Documents library.

Parameters:

jsonSerializer - The serializer to serialize user defined models.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

serviceVersion

public SearchIndexingBufferedSenderBuilder<T> serviceVersion(SearchServiceVersion serviceVersion)

Sets the service version.

Parameters:

serviceVersion - the serviceVersion value.

Returns:

the SearchIndexingBufferedSenderBuilder.

throttlingDelay

public SearchIndexingBufferedSenderBuilder<T> throttlingDelay(Duration throttlingDelay)

Sets the initial duration that requests will be delayed when the service is throttling.

Default value is Duration.ofMillis(800).

Parameters:

throttlingDelay - The initial duration requests will delay when the service is throttling.

Returns:

The updated SearchIndexingBufferedSenderBuilder object.

Applies to