I'm trying to sort my term buckets on score relevancy instead of doc count. I'm trying do to something like this. However, nested field aggregations are not allowed to be added to nested queries.
What are my options?
Here is my current working code (which sorts my term buckets on doc count):
POST myIndex/_search
{
"size": 0,
"aggs": {
"nested_nestedobjects": {
"nested": {
"path": "searchTags_french"
},
"aggs": {
"filtered_nestedobjects": {
"filter": {
"match": {
"searchTags_french.tag": {
"fuzziness": "AUTO",
"operator": "and",
"query": "test query"}
}
},
"aggs": {
"my_agg": {
"terms": {
"size": 20,
"field": "searchTags_french.tag.raw"
}
}
}
}
}
}
}
}
My mapping:
"searchTags_french": {
"type": "nested",
"properties": {
"tag": {
"type": "text",
"analyzer": "completion_analyzer_french",
"search_analyzer": "completion_search_analyzer_french",
"fields": {
"raw": {
"type": "keyword",
"index": "true"
}
}
}
}
}
P.s. I'm using ElasticSearch 6.2