[SERVER-736] Support for XPath like queries Created: 11/Mar/10  Updated: 09/Apr/23

Status: Backlog
Project: Core Server
Component/s: Index Maintenance, JavaScript, Performance, Querying
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: mongonix Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 21
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-267 Wildcard support in index/query/proje... Backlog
is related to MONGOID-4622 Document recursively_embeds_many filt... Closed
is related to SERVER-2989 $elemMatch for querying nested objects Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

It would be very nice to be able to express XPath-like queries with MongoDB.

For example, let's say there is a JSON document that contains a certain subtree, but it is not known where it is inside the JSON
document.

In the XML world, one could use XPath and write something like this to
express relative path (which returns all sub-trees matching the
pattern):
//tree_root_node/subnode1/subnode2 and so on.
But how can somethig like this expressed with MongoDB? According to the documentation found on Mongo web-site, it is only possible to use the following two syntaxes:
1) {tree_root_node: { subnode1 :

{subnode2 : ...}

}}
2)

{ 'tree_root_node.subnode1.subnode2': ...}


in both cases, one needs to know the full path from the JSON document root to the subtree of interest. But it is not known in my case as I
explained before.

And, BTW, it would be really cool if generic XPath queries could be
applied on JSON documents. There are some proposals for JSON based
XPath:
http://goessner.net/articles/JsonPath/
http://bluelinecity.com/software/jpath/
http://somewebguy.wordpress.com/tag/Query/
http://www.hugoware.net/projects/jlinq

(BTW, many XML databases do actually support XPath natively. They even opimize their indexing and storage backends for effective XPath queries evaluation)

Is something like this planned for the future releases? How difficult would it be to implement something like this? Would it require additional, more detailed indexing for effective implementation?

Of course, it is easy to provide support at the syntactic level using whatever syntax (jQuery-like, XPath like, etc) - there are enough libraries for that. But implementing such queries effectively would eventually require new kinds of (additional) indexing, unless you want to iterate over all entries and check each one for the required sub- trees.

Proposal by Eliot: An easy first idea might just be wildcard operator a.*b

Please see this mailing list thread for more information:
http://groups.google.com/group/mongodb-user/browse_thread/thread/d359c8ed8eacddea



 Comments   
Comment by Geoffrey GREBERT [ 09/Apr/23 ]

up please !

Comment by ONIXEDIT [ 21/Aug/18 ]

Hi,

 

What is the status of this request? It is classified as "Major" but still opened since 2010!

 

Thank you

Comment by Andrey Kobyshev [ 06/Dec/12 ]

http://goessner.net/articles/JsonPath/

Comment by Andrey Kobyshev [ 06/Dec/12 ]

Yes, JsonPath functionality is sorely missed in the pyMongo driver...

Generated at Thu Feb 08 02:55:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.