I need to remove a substring contained in one field from another field. However, I don't seem to be able to use the gsub
or grok processors to accomplish this. E.g., I have the following fields:
{
"foo": "foo",
"foobar": "foobar"
}
Desired outcome would be to have the final document look like the following:
{
"fields": {
"foo": "foo",
"foobar": "bar"
}
}
However, the following throws an error:
[
"gsub": {
"field": "fields.foobar",
"pattern": "{{ fields.foo }}",
"replacement": ""
}
]
And the following also fails to create the new field fields.baz: bar
:
[
"grok": {
"field": "fields.foobar",
"pattern": "^{{ fields.foo }}%{DATA:fields.baz}"
}
]
I'm not able to preprocess the value of fields.foobar
prior to sending it to Elasticsearch, which is why I need to do it this way. It seems that there should be a way to do this, perhaps with painless, but I haven't been able to determine it yet.