[SERVER-6250] Operator $or doesn't work Created: 29/Jun/12  Updated: 15/Aug/12  Resolved: 02/Jul/12

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.0.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Roman Schurov Assignee: Daniel Crosta
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

fedora 16 KDE


Operating System: Linux
Participants:

 Description   

> db.artists.find({img : {$exists : false}}).count()
5023
> db.artists.find({$or : [{descr : {$exists : false}}, {img : {$exists : false}}]}).count()
0



 Comments   
Comment by Roman Schurov [ 02/Jul/12 ]

Thanks, Dan.

Comment by Daniel Crosta [ 02/Jul/12 ]

Ah, that explains it. $or was added in version 1.6, so if you need to use it, you will have to upgrade your server.

Comment by Roman Schurov [ 02/Jul/12 ]

db.serverStatus()
{
"version" : "1.4.4",
...

> db.artists.find()
> db.artists.insert({_id: 1, name: "alice"})
> db.artists.insert({_id: 2, name: "bob", img: "bob.jpg"})
> db.artists.insert({_id: 3, name: "carol", descr: "Carol"})
> db.artists.insert({_id: 4, name: "dave", img: "dave.jpg", descr: "Dave"})
> db.artists.find({img: {$exists: false}}).count()
2
> db.artists.find({$or: [{descr: {$exists: false}}, {img: {$exists: false}}]}).count()
0

Comment by Daniel Crosta [ 02/Jul/12 ]

Thanks. I'm not certain why the buildInfo command didn't work – can you check the version of the server you're using? You can find this out with the db.serverStatus() shell helper.

I am still unable to reproduce this – have you been able to create a small reproducable test case? Here's what I've tried:

> db.artists.insert({_id: 1, name: "alice"})
> db.artists.insert({_id: 2, name: "bob", img: "bob.jpg"})
> db.artists.insert({_id: 3, name: "carol", descr: "Carol"})
> db.artists.insert({_id: 4, name: "dave", img: "dave.jpg", descr: "Dave"})
> db.artists.find({img: {$exists: false}}).count()
2
> db.artists.find({$or: [{descr: {$exists: false}}, {img: {$exists: false}}]}).count()
3

If you'd like to share your actual data confidentially, let me know and I can provide information on how to do so.

Comment by Roman Schurov [ 02/Jul/12 ]

Hi Dan.

> db.artists.getIndexes()
[
{
"name" : "id",
"ns" : "ivi.artists",
"key" :

{ "_id" : 1 }

},
{
"v" : 1,
"key" :

{ "s" : 1 }

,
"ns" : "ivi.artists",
"name" : "s_1"
}
]

> db.artists.stats()
{
"ns" : "ivi.artists",
"count" : 7676,
"size" : 25232628,
"storageSize" : 47582464,
"numExtents" : 9,
"nindexes" : 2,
"lastExtentSize" : 13594624,
"paddingFactor" : 1.4999999999998643,
"flags" : 1,
"totalIndexSize" : 794624,
"indexSizes" :

{ "_id_" : 327680, "s_1" : 466944 }

,
"ok" : 1
}

> db.runCommand(

{buildInfo: 1}

)
{ "errmsg" : "no such cmd", "bad cmd" :

{ "buildInfo" : 1 }

, "ok" : 0 }

Comment by Daniel Crosta [ 29/Jun/12 ]

Hi Roman,

I can't reproduce this case, at least not yet. Can you show the output of db.artists.getIndexes(), db.artists.stats(), and db.runCommand(

{buildInfo: 1}

)?

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