SearchIndexingBufferedSender Class

A buffered sender for document indexing actions.

Constructor

SearchIndexingBufferedSender(endpoint: str, index_name: str, credential: AzureKeyCredential | TokenCredential, **kwargs: Any)

Parameters

Name Description
endpoint
Required
str

The URL endpoint of an Azure search service

index_name
Required
str

The name of the index to connect to

credential
Required

A credential to authorize search client requests

Keyword-Only Parameters

Name Description
auto_flush

Whether to automatically flush the batch. Default is True.

auto_flush_interval
int

How many max seconds between 2 flushes. This only takes effect when auto_flush is on. Default to 60 seconds.

initial_batch_action_count
int

The initial number of actions to group into a batch when tuning the behavior of the sender. The default value is 512.

max_retries_per_action
int

The number of times to retry a failed document. The default value is 3.

on_new

If it is set, the client will call corresponding methods when there is a new IndexAction added. This may be called from main thread or a worker thread.

on_progress

If it is set, the client will call corresponding methods when there is a IndexAction succeeds. This may be called from main thread or a worker thread.

on_error

If it is set, the client will call corresponding methods when there is a IndexAction fails. This may be called from main thread or a worker thread.

on_remove

If it is set, the client will call corresponding methods when there is a IndexAction removed from the queue (succeeds or fails). This may be called from main thread or a worker thread.

api_version
str

The Search API version to use for requests.

audience
str

Sets the Audience to use for authentication with Microsoft Entra ID. The audience is not considered when using a shared key. If audience is not provided, the public cloud audience will be assumed.

Methods

close

Close the session.

delete_documents

Queue delete documents actions

flush

Flush the batch.

index_documents

Specify a document operations to perform as a batch.

merge_documents

Queue merge documents actions

merge_or_upload_documents

Queue merge documents or upload documents actions

upload_documents

Queue upload documents actions.

close

Close the session.

close(**kwargs) -> None

Returns

Type Description

None

delete_documents

Queue delete documents actions

delete_documents(documents: List[Dict], **kwargs) -> None

Parameters

Name Description
documents
Required

A list of documents to delete.

flush

Flush the batch.

flush(timeout: int = 86400, **kwargs: Any) -> bool

Parameters

Name Description
timeout
int

Time out setting. Default is 86400s (one day)

Default value: 86400

Returns

Type Description

True if there are errors. Else False

Exceptions

Type Description
azure.core.exceptions.ServiceResponseTimeoutError

index_documents

Specify a document operations to perform as a batch.

index_documents(batch: IndexDocumentsBatch, **kwargs) -> List[IndexingResult]

Parameters

Name Description
batch
Required

A batch of document operations to perform.

Returns

Type Description

Indexing result of each action in the batch.

Exceptions

Type Description

The request is too large.

merge_documents

Queue merge documents actions

merge_documents(documents: List[Dict], **kwargs) -> None

Parameters

Name Description
documents
Required

A list of documents to merge.

merge_or_upload_documents

Queue merge documents or upload documents actions

merge_or_upload_documents(documents: List[Dict], **kwargs) -> None

Parameters

Name Description
documents
Required

A list of documents to merge or upload.

upload_documents

Queue upload documents actions.

upload_documents(documents: List[Dict], **kwargs) -> None

Parameters

Name Description
documents
Required

A list of documents to upload.

Attributes

actions

The list of currently index actions in queue to index.

Returns

Type Description