update_by_query
- class opensearchpy.helpers.update_by_query.UpdateByQuery(**kwargs)[source]
Bases:
Request
Update by query request to opensearch.
- Parameters:
using – OpenSearch instance to use
index – limit the search to index
doc_type – only query this type.
kwargs (Any) –
All the parameters supplied (or omitted) at creation type can be later overridden by methods (using, index and doc_type respectively).
- _clone()[source]
Return a clone of the current search request. Performs a shallow copy of all the underlying objects. Used internally by most state modifying APIs.
- Return type:
- execute()[source]
Execute the search and return an instance of
Response
wrapping all the data.- Return type:
- classmethod from_dict(d)[source]
Construct a new UpdateByQuery instance from a raw dict containing the search body. Useful when migrating from raw dictionaries.
Example:
ubq = UpdateByQuery.from_dict({ "query": { "bool": { "must": [...] } }, "script": {...} }) ubq = ubq.filter('term', published=True)
- script(**kwargs)[source]
Define update action to take:
Note: the API only accepts a single script, so calling the script multiple times will overwrite.
Example:
ubq = Search() ubq = ubq.script(source="ctx._source.likes++"") ubq = ubq.script(source="ctx._source.likes += params.f"", lang="expression", params={'f': 3})
- to_dict(**kwargs)[source]
Serialize the search into the dictionary that will be sent over as the request’ubq body.
All additional keyword arguments will be included into the dictionary.