I'm trying to aggregate over dynamically mapped fields in ElasticSearch.
For example:
POST test/_doc/1
{
"settings": {
"range": {
"value": 200,
"display": "200 km"
},
"transmitter": {
"value": 1.2,
"display": "1.2 Ghz"
}
}
}
The properties under settings
are dynamic. Essentially I need a query like this:
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"settings": {
"terms": {
"field": "settings.*.display"
}
}
}
}
Since *
doesn't work here, I'm wondering if there's a way to return the fields from a painless script and then maybe use a pipeline aggregation? I can't find the painless equivalent to Object.keys(settings)
in JavaScript.
I've seen an approach with nested objects, but I'd like to avoid that, as there might be many 'settings' properties and the default limit is 50, compared to nested_objects with 10000 properties.