I have an elastic search schema of the kind shown below
{
"customer": {
"properties": {
"id": {"type": "string", "index": "not_analyzed"}
}
}
}
{
"activity": {
"parent": {
"type": "customer"
},
"routing": {
"required": true,
"path": "customer.id"
},
"properties": {
...
// The parent object is included on activity
"customer": {
"properties": {
"id": {"type": "string", "index": "not_analyzed"}
}
}
}
}
}
Where, customers have activities and activities are children of customer type. I also have the customer available directly on the activity type.
If I now write a terms filter against the activity type
{
"terms": {
"field": "customer.id"
}
}
Which reads as - bucket all activities belonging to the same customer.
Surprisingly, this buckets activity.id
instead of activity.customer.id
. I'm stumped. Really truly.
I assumed this has something to do with the parent-child relation? I was able to get what I want by doing
{
"terms": {
"field": "_parent"
}
}
I don't understand this. Can someone point out what I'm doing wrong?