Hi, we're using ES 5.5.2, say we got this scenario:
One user searched "Christmas presents", and the results were:
Christmas present A _score: 35.12, price: 100
Christmas present B _score: 34.56, price: 120
Christmas present C _score: 34.33, price: 100
Valentine present A _score: 12.11, price: 80
Valentine present B _score: 12.02, price: 80
Valentine present C _score: 11.45, price: 70
If the user clicked "sort by price asc", the first page's results may be not relevant enough.
We suppose it is better to sort price
in each _score
bucket [0, 10), [10, 20), [20, 30), ...
So we changed the search query to:
{
"from": 0,
"aggs": {},
"query": {
# .....
},
"sort": {
"_script": {
"type": "number",
"script": {
"lang": "painless",
"inline": "doc['price'].value + Math.floor(_score / 10.0) * 100000"
},
"order": "asc"
}
},
"track_scores": true
}
Or is there a better way to perform like this? Thank you for help!