[SERVER-14150] Allow specifying query predicates over document metadata Created: 03/Jun/14  Updated: 10/Dec/14  Resolved: 04/Jun/14

Status: Closed
Project: Core Server
Component/s: Querying, Text Search
Affects Version/s: 2.6.0
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Norberto Fernando Rocha Leite (Inactive) Assignee: hari.khalsa@10gen.com
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

We can return and sort on the $meta textScore.
It would be great to enable to filter on ranges of this value:

db.col.find( {$text:{ $search: "keyword" , $meta.textScore :  {$gt: 0.5} } })



 Comments   
Comment by Eliot Horowitz (Inactive) [ 04/Jun/14 ]

You should be able to already do this with agg, where you project in one stage and filter in another.

Comment by J Rassi [ 03/Jun/14 ]

Fair enough. I'm somewhat hesitant to encourage users to depend on particular text score values, just because they're tied to a particular version of the text index (that is, scores will change in any release of the server where the text index version changes), but it's still worth considering.

The proposal I had for this a while back was more general: allow arbitrary predicates over document metadata, which are evaluated after the metadata is computed. So, the syntax would be something like this:

db.collection.find({score: {$gt: 0.5}, $text: {$search: "foo"}}, {score: {$meta: "textScore"}})

And then you'd be able to use the same mechanism to define an arbitrary predicate over distance for a geo query, for example.

Updating title/priority, assigning to hari.khalsa@10gen.com for triage.

Comment by Norberto Fernando Rocha Leite (Inactive) [ 03/Jun/14 ]

Hi rassi@10gen.com,

Just think about a quality search capability where we want to avoid returning results that do not match a certain relevance score.
If we could define that on the query we would be returning less results but more relevant (or only the ones that match certain relevance).

I'll change the priority to reflect the fact that this might be a not too demanded capability (did not check this before) but still interesting to have feature.

N.

Comment by J Rassi [ 03/Jun/14 ]

norberto@10gen.com: can you describe what the use case you have in mind for this would look like?

Generated at Thu Feb 08 03:34:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.