Support for aggregations without field missing
yatishbalaji opened this issue · comments
Yatish Motamarri commented
For aggregations not done on any field like TopHits, there is no way to get it done.
Similarly for aggregation which has script without field doesn't work
"aggs" : {
"doctype" : {
"terms" : { "field" : "field1", "order": [{ "maxScore": "desc" }] },
"aggs": {
"topHits": {
"top_hits": {
"size": 2,
"_source": ["field1"],
"track_scores" : true,
}
},
"maxScore": {
"max": {
"script": "_score"
}
}
}
}
}
Ferron H commented
bodybuilder()
.aggregation('terms', 'field1', 'doctype', {
order: [{
"maxScore": "desc"
}]
}, (a) => {
return a.aggregation('top_hits', null, 'topHits', {
"size": 2,
"_source": ["field1"],
"track_scores": true,
}).aggregation("max", null, "maxScore", {
script: "_score"
})
})
.build()
==>
{
"aggs": {
"doctype": {
"terms": {
"field": "field1",
"order": [
{
"maxScore": "desc"
}
]
},
"aggs": {
"topHits": {
"top_hits": {
"size": 2,
"_source": [
"field1"
],
"track_scores": true
}
},
"maxScore": {
"max": {
"script": "_score"
}
}
}
}
}
}