Hi all,
I have a index with a nested field like this:
{
"id_single_profile": "14e98c40-d5ed-11e8-aa2a-d991a7f7e009",
"id_audience": "3c9b46e4-1b10-4ad4-9a68-ae371034adfe",
"activities": [
{
"id_activity": "activity-1",
"nm_product": "xx",
"nm_product_category": "WEB",
"nm_establishment_category": "Softwares / APP"
},
{
"id_activity": "activity-2",
"nm_product": "yy",
"nm_product_category": "WEB",
"nm_establishment_category": "Softwares / APP"
}
]
}
So I'm trying to transform each nested object in a new index document. Something like this:
[
{
"_index": "doc1",
"_type": "activity",
"_id": "activity-1",
"_source": {
"nm_product": "xx",
"nm_product_category": "WEB",
"nm_establishment_category": "Softwares / APP"
}
}
{
"_index": "doc1",
"_type": "activity",
"_id": "activity-2",
"_source": {
"nm_product": "yy",
"nm_product_category": "WEB",
"nm_establishment_category": "Softwares / APP"
}
}
]
--
I've been using this filter below in Logstash. I'm splitting by the "activities" nested field and this doing fine. The problem is to remove the nested field from the document after doing the split. When I use the "remove_field" to remove the "activities" field from output the split just don't work.
filter {
split { field => "activities" }
mutate {
add_field => {
"nm_product" => "%{[activities][nm_product]}"
"nm_product_category" => "%{[activities][nm_product_category]}"
"nm_establishment_category" => "%{[activities][nm_establishment_category]}"
}
}
mutate { remove_field => ["@version","@timestamp"] }
}
Is there something I'm missing?
I will appreciate any comments. Thanks!