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 36. Set Options
| Name | Required | Default | Description |
|---|---|---|---|
|
yes |
- |
The field to insert, upsert, or update. Supports template snippets. |
|
yes* |
- |
The value to be set for the field. Supports template snippets. May specify only one of |
|
no |
- |
The origin field which will be copied to |
|
no |
|
If processor will update fields with pre-existing non-null-valued field. When set to |
|
no |
|
If |
|
no |
|
The media type for encoding |
|
no |
- |
Description of the processor. Useful for describing the purpose of the processor or its configuration. |
|
no |
- |
Conditionally execute the processor. See Conditionally run a processor. |
|
no |
|
Ignore failures for the processor. See Handling pipeline failures. |
|
no |
- |
Handle failures for the processor. See Handling pipeline failures. |
|
no |
- |
Identifier for the processor. Useful for debugging and metrics. |
{
"description" : "sets the value of count to 1",
"set": {
"field": "count",
"value": 1
}
}
This processor can also be used to copy data from one field to another. For example:
PUT _ingest/pipeline/set_os
{
"description": "sets the value of host.os.name from the field os",
"processors": [
{
"set": {
"field": "host.os.name",
"value": "{{{os}}}"
}
}
]
}
POST _ingest/pipeline/set_os/_simulate
{
"docs": [
{
"_source": {
"os": "Ubuntu"
}
}
]
}
Result:
{
"docs" : [
{
"doc" : {
"_index" : "_index",
"_id" : "_id",
"_source" : {
"host" : {
"os" : {
"name" : "Ubuntu"
}
},
"os" : "Ubuntu"
},
"_ingest" : {
"timestamp" : "2019-03-11T21:54:37.909224Z"
}
}
}
]
}
The contents of a field including complex values such as arrays and objects can be copied to another field using copy_from:
PUT _ingest/pipeline/set_bar
{
"description": "sets the value of bar from the field foo",
"processors": [
{
"set": {
"field": "bar",
"copy_from": "foo"
}
}
]
}
POST _ingest/pipeline/set_bar/_simulate
{
"docs": [
{
"_source": {
"foo": ["foo1", "foo2"]
}
}
]
}
Result:
{
"docs" : [
{
"doc" : {
"_index" : "_index",
"_id" : "_id",
"_source" : {
"bar": ["foo1", "foo2"],
"foo": ["foo1", "foo2"]
},
"_ingest" : {
"timestamp" : "2020-09-30T12:55:17.742795Z"
}
}
}
]
}