-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Search/SearchSearch-related issues that do not fall into other categoriesSearch-related issues that do not fall into other categories>feature
Description
Describe the feature: First SortMode for Nested Fields
I want to sort documents by attribute of selected inner hit. For example I have a mapping and two documents(red and blue) like these:
PUT test_index
{
"mappings": {
"mydoc": {
"properties": {
"name": {
"type": "keyword"
},
"myNestedList": {
"type": "nested",
"properties": {
"subName": {
"type": "integer"
},
"price": {
"type": "integer"
},
"sortId": {
"type": "integer"
}
}
}
}
}
}
}
PUT test_index/mydoc/1
{
"name": "red",
"myNestedList": [
{
"name": "red_1",
"price": 10,
"sortId": 1
},
{
"name": "red_2",
"price": 25,
"sortId": 2
}
]
}
PUT test_index/mydoc/2
{
"name": "blue",
"myNestedList": [
{
"name": "blue_1",
"price": 15,
"sortId": 2
},
{
"name": "blue_2",
"price": 5,
"sortId": 3
}
]
}
Normally when I sort by price descending, it first bring blue because red_2 has value 25 and blue_1 has value 15. I did this and this is fine.
And i tried sorting with scripts but when i use nested filter it fails.
What I want to do is, when sorting documents by price descending, I want to sort documents according to price of nested document with lowest sortId. In this case I should get first blue then red because blue_1's price 15 is greater than red_1's price 10.
farukterzioglu and shaigbdb
Metadata
Metadata
Assignees
Labels
:Search/SearchSearch-related issues that do not fall into other categoriesSearch-related issues that do not fall into other categories>feature