views:

51

answers:

1

Hi,

I have an application where I'd like to use a NoSQL database, but I still want to do range queries over two different properties, for example select all entries between times T1 and T2 where the noiselevel is smaller than X. On the other hand, I would like to use a NoSQL/Key-Value store because my data is very sparse and diverse, and I do not want to create new tables for every new datatype that I might come across.

I know that you cannot use multiple inequality filters for the Google Datastore (source). I also know that this feature is coming (according to this).
I know that this is also not possible in CouchDB (source).

I think I also more or less understand why this is the case.

Now, this makes me wonder.. Is that the case with all NoSQL databases? Can other NoSQL systems make range queries over two different properties?

How about, for example, Mongo DB? I've looked in the Documentation, but the only thing I've found was the following snippet in their docu:

Note that any of the operators on this page can be combined in the same query document. For example, to find all document where j is not equal to 3 and k is greater than 10, you'd query like so:

db.things.find({j: {$ne: 3}, k: {$gt: 10} });

So they use greater-than and not-equal on two different properties. They don't say anything about two inequalities ;-)

Any input and enlightenment is welcome :-)

+3  A: 

Have you tried? This works fine for me (Finds all rows with k > 1 and k < 3):

db.things.find({k:{$gt:1, $lt:3}});
ircmaxell
Thanks for your trying it out! And to answer your question: No, I have not because I don't have a MongoDB installation. That's pretty stupid, actually. I am installing it now ;-)
pableu
I wouldn't say it's "stupid". I can understand wanting to know the capabilities first. But Mongo is one tool that's so easy to install that it almost doesn't make sense not to (in retrospect)... Good luck either way...
ircmaxell