Description
With the recent addition of text indexes and queries in #82 , there was one part I missed that I did not realise - text queries actually have a text score associated to them. This text score is useful for sorting and even filtering.
Sorting: https://docs.mongodb.com/manual/tutorial/text-search-in-aggregation/#return-results-sorted-by-text-search-score
Filtering: https://docs.mongodb.com/manual/tutorial/text-search-in-aggregation/#match-on-text-score
Sorting wouldn't be terribly hard to add. It would mean changing the text query to act more like SearchGeoNear
and use raw stages. That is would require more than one (one for the search, one for the sort), would mean MongoFrameworkQueryProvider
needs to support multiple stages.
Filtering is just another stage on top BUT to get a filter to work requires the projection of the score in its own stage. Now while this is possible, projecting requires noting every single field you want in every subsequent stage. For filtering, I'm really just wanting to add a single additional field rather than change/remove other fields. I could use the entity mapping in MongoFramework but then all "extra fields" in the DB would be ignored in a projection.