Aggregation of top inner documents?

Hi everbody,

I have a document with nested objects (product and its categories). What I need is to search by a category and know which inner document (category) best matched the search. It is simple with inner_hits.

{
"query": {
"nested": {
"path": "categoryPath",
"query": {
"match": {
"categoryPath.path": {
"query": "children hoodie"
}
}
},
"inner_hits": {
"size": 1
}
}
}

Then I need to get unique names of categories matched. Is it possible to collect it using any aggregation? - to collect unique values of all "best" matched inner hits? thank you:)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.