[SERVER-2302] if a field has a regular filter and $ors, index breaks in Created: 29/Dec/10  Updated: 12/Jul/16  Resolved: 16/May/11

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: 1.9.1

Type: Bug Priority: Major - P3
Reporter: Eliot Horowitz (Inactive) Assignee: Aaron Staple
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-958 Range queries on arrays behave differ... Closed
Related
Operating System: ALL
Participants:

 Description   

db.testcase.drop();
db.testcase.insert( { a : [

{ x : 1 }

,

{ x : 2 }

,

{ x : 3 }

,

{ x : 4 }

] } )

function test(){
print( db.testcase.find(
{
a :

{ x : 1 }

,
"$or" : [ { a :

{ x : 2 }

} , { a :

{ x : 3 }

} ]
}
).count() )
}

// The first find will return a result since there isn't an index
test();

// Now create an index

db.testcase.ensureIndex(

{"a":1}

)

// The same query will not return data now
test();

// Drop the indexes

db.testcase.dropIndexes()

// And it will return data again
test()



 Comments   
Comment by Aaron Staple [ 16/May/11 ]

Addressed in the SERVER-958 fix.

Comment by Aaron Staple [ 25/Apr/11 ]

Actually for this jira:

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-2303 test
Branch: master
https://github.com/mongodb/mongo/commit/06b905b0fd11021444ba964d70ee012b81684bd2

Comment by Eliot Horowitz (Inactive) [ 17/Mar/11 ]

Lets do the other case first and see if this falls out.
We can also just do $and soon as well since its often asked for and might make this work.

Comment by Aaron Staple [ 10/Feb/11 ]

Just to be clear, I'm not advocating the above as a permanent fix, but a temporary measure so we don't have incorrect results near term. What I proposed seems like the simplest of the quick fix options.

Comment by Aaron Staple [ 10/Feb/11 ]

It sounds like we want to do a bunch of refactoring before SERVER-958. One quick way of dealing with this $or jira would be to uassert when a user attempts an $or query with an equality expression on the same field in both an $or clause and outside the $or clauses. Doing a double equality match like this is basically a hacky way of doing an $and expression, and we don't support $and yet.

Comment by Aaron Staple [ 29/Dec/10 ]

If the fix is urgent I could probably do something more quickly though.

Comment by Eliot Horowitz (Inactive) [ 29/Dec/10 ]

I mean in 1.9.0, backported to 1.8.1 likely.

Comment by Aaron Staple [ 29/Dec/10 ]

This kind of sucks, but it's not trivial to fix. A fixed implementation would have a lot in common with the SERVER-958 fix, so I'd recommend working on them at the same time.

Did you mean 1.8.1 in your comment or 1.9.1?

Comment by Eliot Horowitz (Inactive) [ 29/Dec/10 ]

Take a look for 1.7.5
If its easy fix, otherwise 1.8.1

Generated at Thu Feb 08 02:59:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.