I have a nested field in elastic search document with 2 fields:
blog = Nested(
properties={
'id': Integer(),
'rating': Integer()
}
)
An ES document has a list of blogs: blog1, blog2 etc.
I want all the documents with blob.id = x and sorted on the rating field corresponding to that blob. Is it feasible to perform this with an elastic search query without a ranking script. Please advice.
Something like this should do what you need:
{
"query": {
"nested": {
"path": "blog",
"query": {
"term": {
"blog.id": 123
}
}
}
},
"sort": [
{
"blog.rating": {
"order": "asc",
"nested_path": "blog",
"nested_filter": {
"term": {
"blog.id": 123
}
}
}
}
]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.