[DOCS-922] Finding Nodes By Partial Path Created: 21/Dec/12  Updated: 30/Oct/23  Resolved: 27/Jul/16

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: Sam Kleinman (Inactive) Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 7 years, 29 weeks ago

 Description   

Find Nodes by a Partial Path

Suppose we want to find a given node in a tree, given some path through a portion of the tree to that node, and then get back that node, and perhaps also everything below it.

With a materialized paths approach we can do the above. The main thing that needs tweaking is to make the operation fast if there is a path "a..b..c..d..e" to a document and we want to find documents with a path "..b..c..d..". If we are starting from the very top it is easy (and described above in the materialized paths section). However here we aren't starting at the top. One approach is to use a combination of materialized path plus an array of the node's ancestors, something like:

{ path : ",a,b,c,d,e,",
  ancestor : ['a','b','c','d','e'] }

We could index on ancestors which will create a [multikey|DOCS:Multikeys] index. Then we would do a query like the following to find nodes on path "...b,c,d..." with some efficiency:

find({ path : /,b,c,d,/, ancestor : 'd', <more_query_expressions_optionally> })

In the above the index on ancestor would be used and only docs from 'd' down need be inspected. The following could be tried which might be even better depending on how smart the query optimizer is:

find( { path : /,b,c,d,/, ancestor : { $all : ['a','d'] }, ... } )



 Comments   
Comment by Emily Hall [ 27/Jul/16 ]

Closed by Emily Hall for Housekeeping on 7/27/16.
Please create a new ticket if for prioritization.

Thank you!

Comment by Sam Kleinman (Inactive) [ 21/Dec/12 ]

Ephemera from the wiki that I don't think made it into the new guide.

Feel free to close if I missed this?

Generated at Thu Feb 08 07:39:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.