你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

IndexDocumentsBatch Class

Represent a batch of update operations for documents in an Azure Search index.

Index operations are performed in the order in which they are added to the batch.

Constructor

IndexDocumentsBatch(*args: Any, **kwargs: Any)

Keyword-Only Parameters

Name Description
actions
Default value: None

Methods

add_delete_actions

Add documents to delete from the Azure search index.

Delete removes the specified document from the index. Any field you specify in a delete operation, other than the key field, will be ignored. If you want to remove an individual field from a document, use merge_documents instead and set the field explicitly to None.

Delete operations are idempotent. That is, even if a document key does not exist in the index, attempting a delete operation with that key will result in a 200 status code.

add_merge_actions

Add documents to merge in to existing documents in the Azure search index.

Merge updates an existing document with the specified fields. If the document doesn't exist, the merge will fail. Any field you specify in a merge will replace the existing field in the document. This also applies to collections of primitive and complex types.

add_merge_or_upload_actions

Add documents to merge in to existing documents in the Azure search index, or upload if they do not yet exist.

This action behaves like merge if a document with the given key already exists in the index. If the document does not exist, it behaves like upload with a new document.

add_upload_actions

Add documents to upload to the Azure search index.

An upload action is similar to an "upsert" where the document will be inserted if it is new and updated/replaced if it exists. All fields are replaced in the update case.

as_dict

Return a dict that can be turned into json using json.dump.

clear

Remove all items from D.

copy
dequeue_actions

Get the list of currently configured index actions and clear it.

enqueue_actions

Enqueue a list of index actions to index.

get

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

items
keys
pop

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

popitem

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

setdefault

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

update

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

values

add_delete_actions

Add documents to delete from the Azure search index.

Delete removes the specified document from the index. Any field you specify in a delete operation, other than the key field, will be ignored. If you want to remove an individual field from a document, use merge_documents instead and set the field explicitly to None.

Delete operations are idempotent. That is, even if a document key does not exist in the index, attempting a delete operation with that key will result in a 200 status code.

add_delete_actions(*documents: List[Dict] | List[List[Dict]], **kwargs: Any) -> List[IndexAction]

Parameters

Name Description
documents
Required
dict or list[dict]

Documents to delete from an Azure search index. May be a single list of documents, or documents as individual parameters.

Returns

Type Description

the added actions

add_merge_actions

Add documents to merge in to existing documents in the Azure search index.

Merge updates an existing document with the specified fields. If the document doesn't exist, the merge will fail. Any field you specify in a merge will replace the existing field in the document. This also applies to collections of primitive and complex types.

add_merge_actions(*documents: List[Dict] | List[List[Dict]], **kwargs: Any) -> List[IndexAction]

Parameters

Name Description
documents
Required
dict or list[dict]

Documents to merge into an Azure search index. May be a single list of documents, or documents as individual parameters.

Returns

Type Description

the added actions

add_merge_or_upload_actions

Add documents to merge in to existing documents in the Azure search index, or upload if they do not yet exist.

This action behaves like merge if a document with the given key already exists in the index. If the document does not exist, it behaves like upload with a new document.

add_merge_or_upload_actions(*documents: List[Dict] | List[List[Dict]], **kwargs: Any) -> List[IndexAction]

Parameters

Name Description
documents
Required
dict or list[dict]

Documents to merge or upload into an Azure search index. May be a single list of documents, or documents as individual parameters.

Returns

Type Description

the added actions

add_upload_actions

Add documents to upload to the Azure search index.

An upload action is similar to an "upsert" where the document will be inserted if it is new and updated/replaced if it exists. All fields are replaced in the update case.

add_upload_actions(*documents: List[Dict] | List[List[Dict]], **kwargs: Any) -> List[IndexAction]

Parameters

Name Description
documents
Required
dict or list[dict]

Documents to upload to an Azure search index. May be a single list of documents, or documents as individual parameters.

Returns

Type Description

the added actions

as_dict

Return a dict that can be turned into json using json.dump.

as_dict(*, exclude_readonly: bool = False) -> dict[str, Any]

Keyword-Only Parameters

Name Description
exclude_readonly

Whether to remove the readonly properties.

Default value: False

Returns

Type Description

A dict JSON compatible object

clear

Remove all items from D.

clear() -> None

copy

copy() -> Model

dequeue_actions

Get the list of currently configured index actions and clear it.

dequeue_actions(**kwargs: Any) -> List[IndexAction]

Returns

Type Description

the current actions

enqueue_actions

Enqueue a list of index actions to index.

enqueue_actions(new_actions: IndexAction | List[IndexAction], **kwargs: Any) -> None

Parameters

Name Description
new_actions
Required

the actions to enqueue

get

Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any

get(key: str, default: Any = None) -> Any

Parameters

Name Description
key
Required
default
Default value: None

items

items() -> ItemsView[str, Any]

Returns

Type Description

set-like object providing a view on D's items

keys

keys() -> KeysView[str]

Returns

Type Description

a set-like object providing a view on D's keys

pop

Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.

pop(key: str, default: ~typing.Any = <object object>) -> Any

Parameters

Name Description
key
Required
default

popitem

Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.

popitem() -> tuple[str, Any]

setdefault

Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any

setdefault(key: str, default: ~typing.Any = <object object>) -> Any

Parameters

Name Description
key
Required
default

update

Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.

update(*args: Any, **kwargs: Any) -> None

values

values() -> ValuesView[Any]

Returns

Type Description

an object providing a view on D's values

Attributes

actions

The list of currently index actions to index.

Returns

Type Description