Comparison with elasticsearch

Suppose I'm storing data in key, value format in a NoSQL database like MongoDB and I need to get all documents in which a value corresponding to a particular key is <= some value. Is there a proper way of doing this query with elasticsearch?

For eg, I've documents:
{A: 3, B:5}
{A: 2, B:7}
{A: 31, B:10}
{A: 43, B:1} and I want documents with B <= 5, so I get first and last documents.

I know there's a way to do this in MongoDB, but data size is very big (TBs) and I'm looking for a better performance, if there, is with elasticsearch. Thanks.

A range query should do that easily.

1 Like

Thanks for quick reply. I found gte, gt, lte, lt operators. I presume = and != correspond to must and must_not?

Yes. Can be must or filter or should depending on what you want to do.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.