Support sorting on fields of matching embedded documents
The Atlas search functionality allows matching and returning embedded documents from within array fields. However, there is currently no way to sort the results based on a field within the matching embedded documents.
This presents problems for queries where we want deterministic sorting based on an embedded field, rather than using a score-based sort which can have inaccuracies for large values, see https://www.mongodb.com/community/forums/t/function-score-result-in-inaccurate-score/296014
For example, consider data with an "items" array containing embedded documents, where we want to sort the results based on the "number" field within the matching embedded docs. Currently we have to assign this to the score, but scores are not ideal for large values.
It would be much better if we could do a simple sort like: "items.number"