JSONPath query on MongoDB?

750 views
Skip to first unread message

Siddharth Trikha

unread,
Jul 7, 2018, 2:29:28 AM7/7/18
to mongodb-user
We have User data stored into MongoDB. The client gives a JSONPath query to ask for filtered set of users.

Eg:

$.users[@.salary > 10000]

is a JSONPath query given to retrieve users with salary greater than 10000.

Whereas, a MongoQuery for the same would be:

    db.inventory.find( { salary: { $gt: 10000 } })

We have our Application code in Java which connects to MongoDB.

Is there any way I can run this JSONPath query to MongoDB directly ??

Using Mongo query would mean translating the JSONPath query to MongoQuery which would be cumbersome. A very brute force method would be to get all Users first on AS (application) and then convert List<Document> to Json string and then run the JSONPath query.

Any help would be appreciated.

Mohit Dayma

unread,
Jul 7, 2018, 5:32:00 AM7/7/18
to mongod...@googlegroups.com
ya sure you connect with Robomongo software, where you can run query directly.

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/b94e9400-ddb1-4618-8868-1acec0662be0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Siddharth Trikha

unread,
Jul 9, 2018, 12:17:29 AM7/9/18
to mongodb-user
That would be MongoQuery which it would run, I need to run a JSONPath query directly into MongoDB.

Any assistance for that ?

On Saturday, 7 July 2018 15:02:00 UTC+5:30, Dayma Mohit wrote:
ya sure you connect with Robomongo software, where you can run query directly.
On 6 July 2018 at 16:16, Siddharth Trikha <siddhart...@gmail.com> wrote:
We have User data stored into MongoDB. The client gives a JSONPath query to ask for filtered set of users.

Eg:

$.users[@.salary > 10000]

is a JSONPath query given to retrieve users with salary greater than 10000.

Whereas, a MongoQuery for the same would be:

    db.inventory.find( { salary: { $gt: 10000 } })

We have our Application code in Java which connects to MongoDB.

Is there any way I can run this JSONPath query to MongoDB directly ??

Using Mongo query would mean translating the JSONPath query to MongoQuery which would be cumbersome. A very brute force method would be to get all Users first on AS (application) and then convert List<Document> to Json string and then run the JSONPath query.

Any help would be appreciated.

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.

Wan Bachtiar

unread,
Jul 12, 2018, 3:12:05 AM7/12/18
to mongodb-user

I need to run a JSONPath query directly into MongoDB

Hi Siddharth,

This is currently not a suppported feature of MongoDB. There is an open ticket SERVER-736, please feel free to upvote/watch for updates.

Since there is an equivalent in MongoDB Query Language, you could try creating a translation layer between the two.

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages