[SERVER-12173] when $text is in $or, it should be evalutate first Created: 20/Dec/13  Updated: 11/Jul/16  Resolved: 30/Dec/13

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

Type: Task Priority: Major - P3
Reporter: Kay Kim (Inactive) Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-12592 error message unclear for OR with tex... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Description   

I'm able to use $text expression in $or when I shouldn't be.

db.articles.find({  $or: [   { $text: { $search: "bake" } },   { _id: 5 }   ] })

returns

{ "_id" : 5, "subject" : "the cake that came out of the oven" }

And like the ticket regarding $and and two text expression, I'm also allowed currently to do $or and two text expressions. But I figure one of these two tickets would make that situation moot.



 Comments   
Comment by Githook User [ 30/Dec/13 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-12173 Evaluate text nodes first when building solution.
Branch: master
https://github.com/mongodb/mongo/commit/c0ff282b7cf7a70a7f60c44b9f2c2ad8d67bd35e

Comment by J Rassi [ 22/Dec/13 ]

eliot: the current design problem is that the OrStage is non-blocking, and so {$meta:"textScore"} queries with $or can return documents to the user before the TextStage encounters that document, and those documents get assigned the null score (zero). See example:

> db.foo.find({$or:[{_id:0},{$text:{$search:"hello"}}]},{s:{$meta:"textScore"}})
{ "_id" : 0, "a" : "hello", "s" : 0 } // wrong, score should be 1.1 instead of 0
{ "_id" : 1, "a" : "hello world", "s" : 0.75 }
>

Put another way: there's no dependency resolution mechanism that causes the OrStage to buffer the {_id:0} document, such that it is returned only after its score is calculated.

What's your suggestion to fix for 2.6, other than disallowing $text inside $or?

Comment by Eliot Horowitz (Inactive) [ 22/Dec/13 ]

Why do you think you shouldn't be able to do this?

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