I find it interesting that I can't seem to reproduce the issue with a minimal dataset..
DELETE /bug
PUT /bug
{
"mappings": {
"range_agg": {
"properties": {
"id_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"status": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"user": {
"type": "nested",
"properties": {
"id_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"stats": {
"type": "nested",
"properties": {
"id_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"talk_duration_percentage": {
"type": "double"
}
}
}
}
}
},
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "0"
}
}
}
GET /bug/range_agg/_mapping
POST /bug/range_agg
{
"id_string": "42dc82e6-025f-4000-8383-cb24e9d2c002",
"status": "scheduled",
"user": {
"id_string": "42dc82e6-025f-4000-8383-cb24e9d2c002"
},
"stats": {
"id_string": "42dc82e6-025f-4000-8383-cb24e9d2c002",
"talk_duration_percentage": 21
}
}
POST /bug/range_agg
{
"id_string": "d944f1fd-0caa-4000-b33b-8035365bef14",
"status": "scheduled",
"user": {
"id_string": "d944f1fd-0caa-4000-b33b-8035365bef14"
},
"stats": {
"id_string": "d944f1fd-0caa-4000-b33b-8035365bef14",
"talk_duration_percentage": 23
}
}
POST /bug/range_agg
{
"id_string": "df9e6082-0db0-4000-ac48-42ab819a81fd",
"status": "scheduled",
"user": {
"id_string": "df9e6082-0db0-4000-ac48-42ab819a81fd"
},
"stats": {
"id_string": "df9e6082-0db0-4000-ac48-42ab819a81fd",
"talk_duration_percentage": 22
}
}
POST /bug/range_agg
{
"id_string": "e82e754c-04d6-4000-8ce2-1f4baa023cb7",
"status": "completed",
"user": {
"id_string": "e82e754c-04d6-4000-8ce2-1f4baa023cb7"
},
"stats": {
"id_string": "e82e754c-04d6-4000-8ce2-1f4baa023cb7",
"talk_duration_percentage": 25
}
}
POST /bug/range_agg
{
"id_string": "7000f2b4-06a6-4000-8aae-5ffd78bd6f11",
"status": "completed",
"user": {
"id_string": "7000f2b4-06a6-4000-8aae-5ffd78bd6f11"
},
"stats": {
"id_string": "7000f2b4-06a6-4000-8aae-5ffd78bd6f11",
"talk_duration_percentage": 27
}
}
POST /bug/range_agg/_search
{
"query": {
"match_all": {}
},
"aggs": {
"status": {
"terms": {
"field": "status.keyword",
"size": 10
}
}
}
}
POST /bug/range_agg/_search
{
"query": {
"match_all": {}
},
"size": 0,
"from": 0,
"aggs": {
"doc": {
"filter": {
"term": {
"status.keyword": "completed"
}
},
"aggs": {
"stats": {
"nested": {
"path": "stats"
},
"aggs": {
"talk_duration_stats": {
"range": {
"field": "stats.talk_duration_percentage",
"ranges": [
{
"from": 20,
"to": 25
},
{
"from": 25,
"to": 30
}
]
},
"aggs": {
"status": {
"reverse_nested": {},
"aggs": {
"status": {
"terms": {
"field": "status.keyword",
"size": 10
}
}
}
}
}
}
}
}
}
}
}
}