New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested sort inside a top hits inside a reverse nested doesn't work #13420
Comments
@ericrenard if you define the {
"size": 0,
"query": {
"filtered": {
"filter": {
"match_all": {}
}
}
},
"aggs": {
"categories": {
"nested": {
"path": "categories"
},
"aggs": {
"filteredcategories": {
"filter": {
"bool": {
"must": {
"term": {
"categories.type": 1
}
}
}
},
"aggs": {
"top_categories": {
"terms": {
"field": "categories.id"
},
"aggs": {
"top_items": {
"reverse_nested": {},
"aggs": {
"top_items_per_categories": {
"top_hits": {
"sort": [
{
"categories.rank": {
"order": "asc",
"mode": "max",
"nested_path": "categories"
}
}
]
}
}
}
}
}
}
}
}
}
}
}
} The problem is that nested sorting inside I think the automatic detection of the nested path should be removed, because nested sorting is clearer when you tell it what to do. There is a TODO in the code, but I lost track of it. |
Yeah, you're right, it works with nested_path, thanks ! |
…uld always be specified. Closes #13420
Hello,
I'm facing something that looks like a bug. I have a simple document model : my documents are items, and inside these items there are categories.
I want to get a list of categories with a certain type, and for each of these categories, a list of top items belonging to this category, sorted on the category rank. So I'm doing a top hits inside reverse nested
Mapping example :
Some data to test :
Finally the search query :
Ultimately, I want to sort by the category rank of the current bucket but I don't know how to refer to the bucket id inside the sort clause.
Anyways, sorting by any nested property doesn't work (sort doesn't apply). However, sorting by a base property of item do work correctly.
Is this a bug or just me doing my query the wrong way ?
Thanks
The text was updated successfully, but these errors were encountered: