Skip to main content

PutElasticsearchJson

Description

An Elasticsearch put processor that uses the official Elastic REST client libraries. Each FlowFile is treated as a document to be sent to the Elasticsearch _bulk API. Multiple FlowFiles can be batched together into each Request sent to Elasticsearch.

Tags

elasticsearch, elasticsearch5, elasticsearch6, elasticsearch7, elasticsearch8, index, json, put

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
Identifier Attributeput-es-json-id-attrThe name of the FlowFile attribute containing the identifier for the document. If the Index Operation is "index", this property may be left empty or evaluate to an empty value, in which case the document's identifier will be auto-generated by Elasticsearch. For all other Index Operations, the attribute must evaluate to a non-empty value.
Index Operation *put-es-record-index-opindexThe type of the operation used to index (create, delete, index, update, upsert)

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.
Scriptput-es-json-scriptThe script for the document update/upsert. Only applies to Update/Upsert operations. Must be parsable as JSON Object. If left blank, the FlowFile content will be used for document update/upsert

Supports Expression Language, using FlowFile attributes and Environment variables.
Scripted Upsertput-es-json-scripted-upsertfalse
  • true
  • false
Whether to add the scripted_upsert flag to the Upsert Operation. Forces Elasticsearch to execute the Script whether or not the document exists, defaults to false. If the Upsert Document provided (from FlowFile content) will be empty, but sure to set the Client Service controller service's Suppress Null/Empty Values to Never Suppress or no "upsert" doc will be, included in the request to Elasticsearch and the operation will not create a new document for the script to execute against, resulting in a "not_found" error

Supports Expression Language, using FlowFile attributes and Environment variables.
Dynamic Templatesput-es-json-dynamic_templatesThe dynamic_templates for the document. Must be parsable as a JSON Object. Requires Elasticsearch 7+

Supports Expression Language, using FlowFile attributes and Environment variables.
Batch Size *put-es-record-batch-size100The preferred number of FlowFiles to send over in a single batch

Supports Expression Language, using Environment variables.
Character Set *put-es-json-charsetUTF-8Specifies the character set of the document data.

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.
Log Error Responsesput-es-record-log-error-responsesfalse
  • true
  • false
If this is enabled, errors will be logged to the NiFi logs at the error log level. Otherwise, they will only be logged if debug logging is enabled on NiFi as a whole. The purpose of this option is to give the user the ability to debug failed operations without having to turn on debug logging.
Output Error Responsesput-es-output-error-responsesfalse
  • true
  • false
If this is enabled, response messages from Elasticsearch marked as "error" will be output to the "error_responses" relationship.This does not impact the output of flowfiles to the "successful" or "errors" relationships
Treat "Not Found" as Successput-es-not_found-is-errortrue
  • true
  • false
If true, "not_found" Elasticsearch Document associated Records will be routed to the "successful" relationship, otherwise to the "errors" relationship. If Output Error Responses is "true" then "not_found" responses from Elasticsearch will be sent to the error_responses relationship.

Dynamic Properties

NameValueDescription
The name of the Bulk request headerThe value of the Bulk request headerPrefix: BULK: - adds the specified property name/value as a Bulk request header in the Elasticsearch Bulk API body used for processing. If the value is null or blank, the Bulk header will be omitted for the document operation. These parameters will override any matching parameters in the _bulk request body.

Supports Expression Language: Yes, evaluated using FlowFile Attributes and Environment variables.
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 _bulk request body. If FlowFiles are batched, only the first FlowFile in the batch is used to evaluate property values.

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

Relationships

NameDescription
errorsRecord(s)/Flowfile(s) corresponding to Elasticsearch document(s) that resulted in an "error" (within Elasticsearch) will be routed here.
failureAll flowfiles that fail for reasons unrelated to server availability go to this relationship.
originalAll flowfiles that are sent to Elasticsearch without request failures go to this relationship.
retryAll flowfiles that fail due to server/cluster availability go to this relationship.
successfulRecord(s)/Flowfile(s) corresponding to Elasticsearch document(s) that did not result in an "error" (within Elasticsearch) will be routed here.

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
elasticsearch.bulk.errorThe _bulk response if there was an error during processing the document within Elasticsearch.
elasticsearch.put.errorThe error message if there is an issue parsing the FlowFile, sending the parsed document to Elasticsearch or parsing the Elasticsearch response

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

System Resource Considerations

ScopeDescription
MEMORYThe Batch of FlowFiles will be stored in memory until the bulk operation is performed.

See Also

PutElasticsearchRecord