I'm trying to create an array with only one element, so that I can add more elements to it later with elasticsearch action update and script.
When adding an array with two elements like this:
filter {
mutate {
add_field => {"path2" => ["%{path}","5"]}
}
}
I get an array element in elasticsearch like this:
"path2": [
"/path/to/my/file.txt",
"5"
]
But if I remove the "5" and write it like this:
add_field => {"path2" => ["%{path}"]}
I get a "path2" entry in elasticsearch which is not an array:
"path2":"/path/to/my/file.txt"
How can I create an array with only one element in it so that I can add elements to that array later?
Thanks a lot! That worked perfectly.
Is it only possible to add an array with just one element through ruby code? Or is there a way to solve this without having to use the ruby filter plugin?
In case someone is trying to do the same as I do here's my full logstash config:
This config will update "path" with an array of elements where the combination of field1 and field2 are duplicate with something that's already saved in elasticsearch.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.