I just have a question about the type: nested
in the index mappings. Let's say I have documents where I want to aggregate on order.order_items.product.manufacturer.contact.name
. Initially I made my mapping like this
{
"properties": {
"order_items": {
"type": "nested",
"properties": {
"quantity": {
"type": "long"
},
"product": {
"type": "nested",
"properties": {
"name": {
"type": "keyword"
},
"manufacturer": {
"type": "nested",
"properties": {
"name": "{
"type": "keyword"
},
"contact": {
"type": "nested",
"properties": {
"name": {"type": "keyword"}
}
}
}
}
}
}
}
}
...other fields...
}
}
That is, I placed "type": "nested"
on every node of the document tree. But through experimentation it seems like this was unnecessary. Seems like I only needed to put "type":"nested"
only on the contact
nested object. And if I only wanted to aggregate on order.order_items.product.name
, then I only need to apply "type":"nested"
on the product
nested object. I just wanted to confirm my findings with someone who knows this stuff just to make sure I didn't misunderstand anything, or if there's other interesting insights I should be aware about.