When I search a certain query and have lots of results with the same search score, I’ve noticed that each time I run the query, the default sorting of results tend to change each time I run the query.
My concern is that when I do pagination with $limit & $skip I may not get expected results because the sort order is changing for subsequent $skip queries.
If I could $sort on the searchScore first, then _id second (or created date or whatever), I could solve that issue in a simple way.
The examples I’ve seen require you to $project the $meta.searchScore before you can $sort on it.
The problem with that is then I need to specify all the other fields I want to $project. I want to include all the other fields without specifying them because they could change and I don’t want to have to remember to update the search code whenever another field is added to the collection.
Is there a way I can tell $project to include all fields, or, is there a way to $sort on searchScore without using the $project stage?
Regarding searchScore, documents in the result set are returned in order from highest score to lowest for Atlas Search by default so you don’t need to include an addition descending $sort on the score. The screenshot is cut out but my guess is that the first stage shown in that screenshot is a $project for the searchScore but let me know if this is not the case. If so, it does appear that the results are appearing from highest to lowest score as expected.
Is there a difference between textScore and searchScore?