I have a situation where I have documents with multiple histogram fields. I would sometimes like to get the percentile of combined fields.
Here is a sample mapping
PUT /t1
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
},
"mappings": {
"properties": {
"myDocId":{"type":"keyword"},
"field_1": {
"properties": {
"histogram": {"type": "histogram"}
}
},
"field_2": {
"properties": {
"histogram": {"type": "histogram"}
}
}
}
}
}
Here we can load a few documents
PUT t1/_doc/1
{
"myDocId": "md_1",
"field_1": {
"histogram": {
"values": [10,12,15,17,20],
"counts": [3,7,23,12,6]
}
},
"field_2": {
"histogram": {
"values": [21,23],
"counts": [3,5]
}
}
}
PUT t1/_doc/2
{
"myDocId": "md_2",
"field_1": {
"histogram": {
"values": [21,23,24,26,28],
"counts": [3,7,23,12,6]
}
},
"field_2": {
"histogram": {
"values": [29,32],
"counts": [3,5]
}
}
}
I know I can get the percentile of single doc field by grouping on myDocId or going across multiple documents on the same field like:
GET t1/_search
{
"size": 0,
"aggs": {
"percentile_field1": {
"percentiles": {
"field": "field_1.histogram"
}
}
}
}
But what I can't seem to get is combining field_1 and field_2 together to pass into the percentile agg. Any thoughts?
thanks --