Package com.azure.search.documents
Class SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T>
java.lang.Object
com.azure.search.documents.SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T>
- Type Parameters:
T
- The type of the document that the buffered sender will use.
- Enclosing class:
- SearchClientBuilder
This class provides a fluent builder API to help aid the configuration and instantiation of
SearchIndexingBufferedSenders
and SearchIndexingBufferedAsyncSenders
. Call buildSender()
and buildAsyncSender()
respectively to
construct an instance of the desired sender.-
Method Summary
Modifier and TypeMethodDescriptionautoFlush
(boolean autoFlush) Sets the flag determining whether a buffered sender will automatically flush its document batch based on the configurations ofautoFlushInterval(Duration)
andinitialBatchActionCount(int)
.autoFlushInterval
(Duration autoFlushInterval) Sets the duration between a buffered sender sending documents to be indexed.Creates aSearchIndexingBufferedAsyncSender
based on options set in the builder.Creates aSearchIndexingBufferedSender
based on options set in the builder.documentKeyRetriever
(Function<T, String> documentKeyRetriever) Sets the function that retrieves the key value from a document.initialBatchActionCount
(int initialBatchActionCount) Sets the number of documents before a buffered sender will send the batch to be indexed.maxRetriesPerAction
(int maxRetriesPerAction) Sets the number of times an action will retry indexing before it is considered failed.maxThrottlingDelay
(Duration maxThrottlingDelay) Sets the maximum duration that requests will be delayed when the service is throttling.onActionAdded
(Consumer<OnActionAddedOptions<T>> onActionAddedConsumer) Callback hook for when a document indexing action has been added to a batch queued.onActionError
(Consumer<OnActionErrorOptions<T>> onActionErrorConsumer) Sets the callback hook for when a document indexing action has failed to index and isn't retryable.onActionSent
(Consumer<OnActionSentOptions<T>> onActionSentConsumer) Sets the callback hook for when a document indexing has been sent in a batching request.onActionSucceeded
(Consumer<OnActionSucceededOptions<T>> onActionSucceededConsumer) Sets the callback hook for when a document indexing action has successfully completed indexing.throttlingDelay
(Duration throttlingDelay) Sets the initial duration that requests will be delayed when the service is throttling.
-
Method Details
-
buildSender
Creates aSearchIndexingBufferedSender
based on options set in the builder. Every time this is called a new instance ofSearchIndexingBufferedSender
is created.- Returns:
- A SearchIndexingBufferedSender with the options set from the builder.
- Throws:
NullPointerException
- IfindexName
,endpoint
, ordocumentKeyRetriever
are null.IllegalStateException
- If bothSearchClientBuilder.retryOptions(RetryOptions)
andSearchClientBuilder.retryPolicy(RetryPolicy)
have been set.
-
buildAsyncSender
Creates aSearchIndexingBufferedAsyncSender
based on options set in the builder. Every time this is called a new instance ofSearchIndexingBufferedAsyncSender
is created.- Returns:
- A SearchIndexingBufferedAsyncSender with the options set from the builder.
- Throws:
NullPointerException
- IfindexName
,endpoint
, ordocumentKeyRetriever
are null.IllegalStateException
- If bothSearchClientBuilder.retryOptions(RetryOptions)
andSearchClientBuilder.retryPolicy(RetryPolicy)
have been set.
-
autoFlush
Sets the flag determining whether a buffered sender will automatically flush its document batch based on the configurations ofautoFlushInterval(Duration)
andinitialBatchActionCount(int)
.- Parameters:
autoFlush
- Flag determining whether a buffered sender will automatically flush.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
-
autoFlushInterval
public SearchClientBuilder.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)
or by a manual trigger.If
autoFlushInterval
is negative or zero andautoFlush(boolean)
is enabled the buffered sender will only flush wheninitialBatchActionCount(int)
is met.- Parameters:
autoFlushInterval
- Duration between document batches being sent for indexing.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
- Throws:
NullPointerException
- IfautoFlushInterval
is null.
-
initialBatchActionCount
public SearchClientBuilder.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 is512
.- Parameters:
initialBatchActionCount
- The number of documents in a batch that will trigger it to be indexed.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
- Throws:
IllegalArgumentException
- IfbatchSize
is less than one.
-
maxRetriesPerAction
public SearchClientBuilder.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.
- Throws:
IllegalArgumentException
- IfmaxRetriesPerAction
is less than one.
-
throttlingDelay
public SearchClientBuilder.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.
- Throws:
IllegalArgumentException
- IfthrottlingDelay.isNegative()
orthrottlingDelay.isZero()
is true.NullPointerException
- IfthrottlingDelay
is null.
-
maxThrottlingDelay
public SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T> maxThrottlingDelay(Duration maxThrottlingDelay) Sets the maximum duration that requests will be delayed when the service is throttling.If
maxThrottlingDelay
is less thanthrottlingDelay(Duration)
thenthrottlingDelay(Duration)
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.
- Throws:
IllegalArgumentException
- IfmaxThrottlingDelay.isNegative()
ormaxThrottlingDelay.isZero()
is true.NullPointerException
- IfmaxThrottlingDelay
is null.
-
onActionAdded
public SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T> onActionAdded(Consumer<OnActionAddedOptions<T>> onActionAddedConsumer) Callback hook for when a document indexing action has been added to a batch queued.- Parameters:
onActionAddedConsumer
- TheConsumer
that is called when a document has been added to a batch queue.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
-
onActionSucceeded
public SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T> onActionSucceeded(Consumer<OnActionSucceededOptions<T>> onActionSucceededConsumer) Sets the callback hook for when a document indexing action has successfully completed indexing.- Parameters:
onActionSucceededConsumer
- TheConsumer
that is called when a document has been successfully indexing.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
-
onActionError
public SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T> onActionError(Consumer<OnActionErrorOptions<T>> onActionErrorConsumer) Sets the callback hook for when a document indexing action has failed to index and isn't retryable.- Parameters:
onActionErrorConsumer
- TheConsumer
that is called when a document has failed to index and isn't retryable.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
-
onActionSent
public SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T> onActionSent(Consumer<OnActionSentOptions<T>> onActionSentConsumer) Sets the callback hook for when a document indexing has been sent in a batching request.- Parameters:
onActionSentConsumer
- TheConsumer
that is called when a document has been sent in a batch request.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
-
documentKeyRetriever
public SearchClientBuilder.SearchIndexingBufferedSenderBuilder<T> documentKeyRetriever(Function<T, String> documentKeyRetriever) Sets the function that retrieves the key value from a document.- Parameters:
documentKeyRetriever
- Function that retrieves the key from anIndexAction
.- Returns:
- The updated SearchIndexingBufferedSenderBuilder object.
- Throws:
NullPointerException
- IfdocumentKeyRetriever
is null.
-