Skip to main content

UpdateByQueryElasticsearch

Description

Update documents in an Elasticsearch index using a query. The query can be loaded from a flowfile body or from the Query parameter. The loaded Query can contain any JSON accepted by Elasticsearch's _update_by_query API, for example a "query" object to identify what documents are to be updated, plus a "script" to define the updates to perform.

Tags

elastic, elasticsearch, elasticsearch5, elasticsearch6, elasticsearch7, elasticsearch8, query, update

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Query Definition Style *el-rest-query-definition-styleFULL_QUERY
  • FULL_QUERY
  • BUILD_QUERY
How the JSON Query will be defined for use by the processor.
Queryel-rest-queryA query in JSON syntax, not Lucene syntax. Ex: {"query":{"match":{"somefield":"somevalue"}}}. If this parameter is not set, the query will be read from the flowfile content. If the query (property and flowfile content) is empty, a default empty JSON Object will be used, which will result in a "match_all" query in Elasticsearch.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Query Definition Style has a value of full
Query Clauseel-rest-query-clauseA "query" clause in JSON syntax, not Lucene syntax. Ex: {"match":{"somefield":"somevalue"}}. If the query is empty, a default JSON Object will be used, which will result in a "match_all" query in Elasticsearch.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Query Definition Style has a value of build
Scriptel-rest-scriptA "script" to execute during the operation, in JSON syntax. Ex: {"source": "ctx._source.count++", "lang": "painless"}

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Query Definition Style has a value of build
Query Attributeel-query-attributeIf set, the executed query will be set on each result flowfile in the specified attribute.

Supports Expression Language, using FlowFile attributes and Environment variables.
Index *el-rest-fetch-indexThe name of the index to use.

Supports Expression Language, using FlowFile attributes and Environment variables.
Typeel-rest-typeThe type of this document (used by Elasticsearch for indexing and searching).

Supports Expression Language, using FlowFile attributes and Environment variables.
Max JSON Field String Length *Max JSON Field String Length20 MBThe maximum allowed length of a string value when parsing a JSON document or attribute.
Client Service *el-rest-client-serviceController Service:
ElasticSearchClientService

Implementations:
ElasticSearchClientServiceImpl
An Elasticsearch client service to use for running queries.

Dynamic Properties

NameValueDescription
The name of a URL query parameter to addThe value of the URL query parameterAdds the specified property name/value as a query parameter in the Elasticsearch URL used for processing. These parameters will override any matching parameters in the query request body

Supports Expression Language: Yes, evaluated using FlowFile Attributes and Environment variables.

Relationships

NameDescription
failureIf the "by query" operation fails, and a flowfile was read, it will be sent to this relationship.
retryAll flowfiles that fail due to server/cluster availability go to this relationship.
successIf the "by query" operation succeeds, and a flowfile was read, it will be sent to this relationship.

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
elasticsearch.update.errorThe error message provided by Elasticsearch if there is an error running the update.
elasticsearch.update.tookThe amount of time that it took to complete the update operation in ms.

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component allows an incoming relationship.

System Resource Considerations

This component does not specify system resource considerations.

See Also