Create and add to a nested fields based on previous data in logstash

Hi,
I have a use case in which I have a data set with "Account Name" , "city", "country". My input is a .csv file.

Example data:

AccountName city country
ABC CA GH
XYZ LA CD
ABC XY JH

Problem statement:
whenever the same Account Name comes, I need to put the "city" and "country" in the array of "location" field.

My Mapping:

Put data
{
mappings:{
properties:{
"Account Name":{
type: text},
"location":{
properties:{
city:{
type: text
},
"country:{
type: text
}
}
}
}
}

Now the logstash file is:

input {

file 
}
filter{
mutate:
{

rename:
{
"City_" => "[location][City]"

"Country_" => "[location][Country]"
}
}}

output{

}

Please help me how to compare the pre-existing data with the new data.

Static comparison with if [Account Name]== %{Account Name}% doesn't help my case or may be I am missing something.

Thanks in advance

Best,

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.