Sorting by Fields After Text Score

Hello,

I was wondering if elastic has the ability to sort by certain indexed fields in a document but not prioritize them over the textual match...

For instance, lets say i have an index of products that has the following items:

{"_id": 1, "title" : "black headphones XM4", "product_rating": 91, "maker": "Sony", "maker_rating": 93}
{"_id": 2, "title" : "black headphones XM5", "product_rating": 89, "maker": "Sony", "maker_rating": 93}
{"_id": 3, "title" : "black headphones", "product_rating": 32, "maker": "AliBaba", "maker_rating": 34}
{"_id": 4, "title" : "white headphones", "product_rating": 91, "maker": "Sony", "maker_rating": 93}

and a user searches for "black headphones"

I would like to get the most textually matching results sure. But I also want to make sure to display them according to the highest maker rating and then the highest product ratings. So in my perfect world i would like elastic to return _ids 1,2,3,4 in that order.

Is there any way to write an elastic query that can accomplish this behavior ?

Thank you in advance

Hi @AymanHamdoun

Did you use sort with the two mentioned fields?
I think it shouldn't work perfectly in the order you want. In your case I would try to use the field value factor to get the results in the desired order using the rating fields along with the score.

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