Question

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 :-)

Was it helpful?

Solution

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}});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top