Back to Elasticsearch

CSV processor [csv-processor]

docs/reference/enrich-processor/csv-processor.md

9.4.02.2 KB
Original Source

CSV processor [csv-processor]

Extracts fields from CSV line out of a single text field within a document. Any empty field in CSV will be skipped.

$$$csv-options$$$

NameRequiredDefaultDescription
fieldyes-The field to extract data from
target_fieldsyes-The array of fields to assign extracted values to
separatorno,Separator used in CSV, has to be single character string
quoteno"Quote used in CSV, has to be single character string
ignore_missingnofalseIf true and field does not exist, the processor quietly exits without modifying the document
trimnofalseTrim whitespaces in unquoted fields
empty_valueno-Value used to fill empty fields, empty fields will be skipped if this is not provided. Empty field is one with no value (2 consecutive separators) or empty quotes ("")
descriptionno-Description of the processor. Useful for describing the purpose of the processor or its configuration.
ifno-Conditionally execute the processor. See Conditionally run a processor.
ignore_failurenofalseIgnore failures for the processor. See Handling pipeline failures.
on_failureno-Handle failures for the processor. See Handling pipeline failures.
tagno-Identifier for the processor. Useful for debugging and metrics.
js
{
  "csv": {
    "field": "my_field",
    "target_fields": ["field1", "field2"]
  }
}

% NOTCONSOLE

If the trim option is enabled then any whitespace in the beginning and in the end of each unquoted field will be trimmed. For example with configuration above, a value of A, B will result in field field2 having value {{nbsp}}B (with space at the beginning). If trim is enabled A, B will result in field field2 having value B (no whitespace). Quoted fields will be left untouched.