Hi
I have an HTTP JSON Input as follows :
{
"mapping": {
"index": "indexname",
"activity": {
"action": "script_update",
"fieldList": ["field1","field2"]
},
"document_type": "_doc",
"document_id": "1",
"routing": "1"
}
}
I have converted the above data in @metadata fields as it was not needed in final elasticsearch output.
Now I need to run a script in which I need to iterate on the "fieldList" array of @metadata and access each element as seperate String.
Currently I am unable to convert the String to array of comma separated string (from @metadata).
I have tried using mutate + split filter but it didn't work.
input{
http {
host => "127.0.0.1"
port => 8080
}
}
filter{
mutate{
add_field => {
"[@metadata][index]" => "%{[mapping][index]}"
}
}
mutate{
add_field => {
"[@metadata][action]" => "%{[mapping][activity][action]}"
}
}
mutate{
add_field => {
"[@metadata][fieldlist]" => "%{[mapping][activity][fieldlist]}"
}
}
mutate{
add_field => {
"[@metadata][userId]" => "%{[mapping][activity][userId]}"
}
}
mutate{
add_field => {
"[@metadata][document_id]" => "%{[mapping][document_id]}"
}
}
mutate{
add_field => {
"[@metadata][document_type]" => "%{[mapping][document_type]}"
}
}
mutate{
add_field => {
"[@metadata][routing]" => "%{[mapping][routing]}"
}
}
}
output{
if [@metadata][action] == "script_update" {
stdout { codec => rubydebug { metadata => true }}
elasticsearch{
hosts => ["localhost:9200"]
index => "%{[@metadata][index]}"
document_type => "%{[@metadata][document_type]}"
document_id => "%{[@metadata][document_id]}"
routing => "%{[@metadata][routing]}"
action => "update"
script_lang => "painless"
script_type => "inline"
script => ' '
/* Add script to iterate on field list and update the corresponding field in elasticsearch with value 2 */
}
}
}
Any help would be appreciated.