Set processor

Sets one field and associates it with the specified value. If the field already exists, its value will be replaced with the provided one.

Table 32. Set Options

NameRequiredDefaultDescription

field

yes

-

The field to insert, upsert, or update. Supports template snippets.

value

yes

-

The value to be set for the field. Supports template snippets.

override

no

true

If processor will update fields with pre-existing non-null-valued field. When set to false, such fields will not be touched.

ignore_empty_value

no

false

If true and value is a template snippet that evaluates to null or the empty string, the processor quietly exits without modifying the document

if

no

-

Conditionally execute this processor.

on_failure

no

-

Handle failures for this processor. See Handling Failures in Pipelines.

ignore_failure

no

false

Ignore failures for this processor. See Handling Failures in Pipelines.

tag

no

-

An identifier for this processor. Useful for debugging and metrics.

  1. {
  2. "description" : "sets the value of count to 1"
  3. "set": {
  4. "field": "count",
  5. "value": 1
  6. }
  7. }

This processor can also be used to copy data from one field to another. For example:

  1. PUT _ingest/pipeline/set_os
  2. {
  3. "description": "sets the value of host.os.name from the field os",
  4. "processors": [
  5. {
  6. "set": {
  7. "field": "host.os.name",
  8. "value": "{{os}}"
  9. }
  10. }
  11. ]
  12. }
  13. POST _ingest/pipeline/set_os/_simulate
  14. {
  15. "docs": [
  16. {
  17. "_source": {
  18. "os": "Ubuntu"
  19. }
  20. }
  21. ]
  22. }

Result:

  1. {
  2. "docs" : [
  3. {
  4. "doc" : {
  5. "_index" : "_index",
  6. "_type" : "_doc",
  7. "_id" : "_id",
  8. "_source" : {
  9. "host" : {
  10. "os" : {
  11. "name" : "Ubuntu"
  12. }
  13. },
  14. "os" : "Ubuntu"
  15. },
  16. "_ingest" : {
  17. "timestamp" : "2019-03-11T21:54:37.909224Z"
  18. }
  19. }
  20. }
  21. ]
  22. }