I would like to change the subject of this post from "Using OR in your
queries makes kittens cry" to "You guys are awesome and make me happy"
Thanks for the quick reply and the heads up.
> Another good reference for doing more simpleortype queries is here:
http://www.mongodb.org/display/DOCS/OR+operations+in+query+expressions
>
> On Aug 26, 2009, at 3:09 PM, Randy wrote:
>
>
>
> > -- Query,OR, and you.
>
> > I am investigating MongoDb, because 1) it's cool, 2) I'm sick of SQL,
> > and 3) I'm tired of schemas.
>
> > Why is there a limitation on usingORtype queries? ORtype queries
> > would be really nice and enable some complicated queries while using
> > the easy to use JSON-style query format.
>
> > I want to be able to query "a == 1orb == 2" in my collections. And
> > it would be nice if I could hit the indexes. It would be double nice
> > if I could use the hash style queries.
>
> > I understand that you can always use query directly on the server by
> > passing in javascript via $where. But it doesn't use the indexes.
>
> > What if you could pass in multiple hashes to the find() method and
> > those would be anORcondition.
>
> > Here's my snippet from the mongodb JS console:
>
> >> db.test.find()
> > {"_id" : "4a9580743b19b3097669443b" , "a" : 1}
> > {"_id" : "4a9580823b19b3097669443c" , "b" : 2}
> > {"_id" : "4a9580993b19b3097669443d" , "b" : 2}
> > {"_id" : "4a95809f3b19b3097669443e" , "b" : 2}
> > {"_id" : "4a9580bc3b19b3097669443f" , "b" : 2}
> > {"_id" : "4a9580c03b19b30976694440" , "c" : 3}
> >> db.test.count({a:1})
> > 1
> >> db.test.count({b:2})
> > 4
> >> db.test.count({b:2},{a:1}) # <=== HypotheticalORquery. this.b
> >> == 2orthis.a ==1. Doesn't work. :()
> > 4
> >> db.test.count("this.b == 2 || this.a == 1")
> > 5
> >> db.test.count({a:1, b:2}) # AND query
> > 0
>
> > Here's a snippet from my IRB console using the Ruby driver. This
> > shows that the $where clause typeORqueries are not using the index.