PutElasticsearchRecord

Description:

A record-aware Elasticsearch put processor that uses the official Elastic REST client libraries. Each Record within the FlowFile is converted into a document to be sent to the Elasticsearch _bulk APi. Multiple documents can be batched into each Request sent to Elasticsearch. Each document's Bulk operation can be configured using Record Path expressions.

Additional Details...

Tags:

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

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Index Operationput-es-record-index-opindexThe type of the operation used to index (create, delete, index, update, upsert)
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Indexel-rest-fetch-indexThe name of the index to use.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Typeel-rest-typeThe type of this document (used by Elasticsearch for indexing and searching).
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
@timestamp Valueput-es-record-at-timestampThe value to use as the @timestamp field (required for Elasticsearch Data Streams)
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Client Serviceel-rest-client-serviceController Service API:
ElasticSearchClientService
Implementation: ElasticSearchClientServiceImpl
An Elasticsearch client service to use for running queries.
Record Readerput-es-record-readerController Service API:
RecordReaderFactory
Implementations: GrokReader
JsonTreeReader
WindowsEventLogReader
ReaderLookup
ParquetReader
CSVReader
Syslog5424Reader
ExcelReader
CEFReader
XMLReader
ScriptedReader
SyslogReader
JsonPathReader
AvroReader
YamlTreeReader
The record reader to use for reading incoming records from flowfiles.
Batch Sizeput-es-record-batch-size100The number of records to send over in a single batch.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
ID Record Pathput-es-record-id-pathA record path expression to retrieve the ID field for use with Elasticsearch. If left blank the ID will be automatically generated by Elasticsearch.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Retain ID (Record Path)put-es-record-retain-id-fieldfalse
  • true
  • false
Whether to retain the existing field used as the ID Record Path.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the [ID Record Path] Property has a value specified.
Index Operation Record Pathput-es-record-index-op-pathA record path expression to retrieve the Index Operation field for use with Elasticsearch. If left blank the Index Operation will be determined using the main Index Operation property.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Index Record Pathput-es-record-index-record-pathA record path expression to retrieve the index field for use with Elasticsearch. If left blank the index will be determined using the main index property.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Type Record Pathput-es-record-type-record-pathA record path expression to retrieve the type field for use with Elasticsearch. If left blank the type will be determined using the main type property.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
@timestamp Record Pathput-es-record-at-timestamp-pathA RecordPath pointing to a field in the record(s) that contains the @timestamp for the document. If left blank the @timestamp will be determined using the main @timestamp property
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Retain @timestamp (Record Path)put-es-record-retain-at-timestamp-fieldfalse
  • true
  • false
Whether to retain the existing field used as the @timestamp Record Path.
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

This Property is only considered if the [@timestamp Record Path] Property has a value specified.
Script Record Pathput-es-record-script-pathA RecordPath pointing to a field in the record(s) that contains the script for the document update/upsert. Only applies to Update/Upsert operations. Field must be Map-type compatible (e.g. a Map or a Record) or a String parsable into a JSON Object
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Scripted Upsert Record Pathput-es-record-scripted-upsert-pathA RecordPath pointing to a field in the record(s) that contains the scripted_upsert boolean flag. 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: true (will be evaluated using flow file attributes and variable registry)
Dynamic Templates Record Pathput-es-record-dynamic-templates-pathA RecordPath pointing to a field in the record(s) that contains the dynamic_templates for the document. Field must be Map-type compatible (e.g. a Map or Record) or a String parsable into a JSON Object. Requires Elasticsearch 7+
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)
Date Formatput-es-record-at-timestamp-date-formatSpecifies the format to use when writing Date fields. If not specified, the default format 'yyyy-MM-dd' is used. If specified, the value must match the Java Simple Date Format (for example, MM/dd/yyyy for a two-digit month, followed by a two-digit day, followed by a four-digit year, all separated by '/' characters, as in 01/25/2017).
Supports Expression Language: true (will be evaluated using variable registry only)
Time Formatput-es-record-at-timestamp-time-formatSpecifies the format to use when writing Time fields. If not specified, the default format 'HH:mm:ss' is used. If specified, the value must match the Java Simple Date Format (for example, HH:mm:ss for a two-digit hour in 24-hour format, followed by a two-digit minute, followed by a two-digit second, all separated by ':' characters, as in 18:04:15).
Supports Expression Language: true (will be evaluated using variable registry only)
Timestamp Formatput-es-record-at-timestamp-timestamp-formatSpecifies the format to use when writing Timestamp fields. If not specified, the default format 'yyyy-MM-dd HH:mm:ss' is used. If specified, the value must match the Java Simple Date Format (for example, MM/dd/yyyy HH:mm:ss for a two-digit month, followed by a two-digit day, followed by a four-digit year, all separated by '/' characters; and then followed by a two-digit hour in 24-hour format, followed by a two-digit minute, followed by a two-digit second, all separated by ':' characters, as in 01/25/2017 18:04:15).
Supports Expression Language: true (will be evaluated using variable registry only)
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 "success" or "errors" relationships
Result Record Writerput-es-record-error-writerController Service API:
RecordSetWriterFactory
Implementations: FreeFormTextRecordSetWriter
CSVRecordSetWriter
ParquetRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
JsonRecordSetWriter
AvroRecordSetWriter
If this configuration property is set, the response from Elasticsearch will be examined for failed records and the failed records will be written to a record set with this record writer service and sent to the "errors" relationship. Successful records will be written to a record set with this record writer service and sent to the "successful_records" relationship.
Treat "Not Found" as Successput-es-record-not_found-is-errortrue
  • true
  • false
If true, "not_found" Elasticsearch Document associated Records will be routed to the "successful_records" 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.

This Property is only considered if the [Result Record Writer] Property has a value specified.
Group Results by Bulk Error Typeput-es-record-bulk-error-groupsfalse
  • true
  • false
If this configuration property is set, the response from Elasticsearch will be examined for _bulk errors. The failed records written to the "errors" relationship will be grouped by error type and the error related to the first record within the FlowFile added to the FlowFile as "elasticsearch.bulk.error". If "Treat "Not Found" as Success" is "false" then records associated with "not_found" Elasticsearch document responses will also be send to the "errors" relationship.

This Property is only considered if the [Result Record Writer] Property has a value specified.

Dynamic Properties:

Supports Sensitive Dynamic Properties: No

Dynamic Properties allow the user to specify both the name and value of a property.

NameValueDescription
The name of the Bulk request headerA Record Path expression to retrieve the Bulk request header valuePrefix: BULK: - adds the specified property name/value as a Bulk request header in the Elasticsearch Bulk API body used for processing. If the Record Path expression results in a null or blank value, 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: true (will be evaluated using flow file attributes and variable registry)
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
Supports Expression Language: true (will be evaluated using flow file attributes and variable registry)

Relationships:

NameDescription
retryAll flowfiles that fail due to server/cluster availability go to this relationship.
successAll flowfiles that succeed in being transferred into Elasticsearch go here. Documents received by the Elasticsearch _bulk API may still result in errors on the Elasticsearch side. The Elasticsearch response will need to be examined to determine whether any Document(s)/Record(s) resulted in errors.
successful_recordsIf a "Result Record Writer" is set, any Record(s) corresponding to Elasticsearch document(s) that did not result in an "error" (within Elasticsearch) will be routed here.
failureAll flowfiles that fail for reasons unrelated to server availability go to this relationship.
errorsIf a "Result Record Writer" is set, any Record(s) corresponding to Elasticsearch document(s) that resulted in an "error" (within Elasticsearch) will be routed here.

Reads Attributes:

None specified.

Writes Attributes:

NameDescription
elasticsearch.put.errorThe error message if there is an issue parsing the FlowFile records, sending the parsed documents to Elasticsearch or parsing the Elasticsearch response.
elasticsearch.put.error.countThe number of records that generated errors in the Elasticsearch _bulk API.
elasticsearch.put.success.countThe number of records that were successfully processed by the Elasticsearch _bulk API.
elasticsearch.bulk.errorThe _bulk response if there was an error during processing the record within Elasticsearch.

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:

ResourceDescription
MEMORYThe Batch of Records will be stored in memory until the bulk operation is performed.

See Also:

PutElasticsearchJson