lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emanuel Schleussinger <>
Subject Querying fragments of a tree structure
Date Wed, 21 Mar 2007 09:39:29 GMT

first, thanks for this great a resource, and sorry if i am oversimplfying a few things, i
am still rather new to Lucene.

I have been thinking how to integrate my app with Lucene - it is a CMS type system that has
documents organized in a tree-style layout. A few facts about the system:
 - Every node in the system is represented by a unique numeric id in  a field called "id"

 - There is one deinfed root node, and an arbitrary amount of descendants. 
 - Each of the nodes on any level knows his descendants in a field called "child" 
 - Each node also knows his parent node in a field called "parent"

I am indexing all the fields from all the nodes in Lucene already, and thus, i can use Lucene
to e.g. get all the descendant node IDs of a node simply by issuing a query like "id:2" and
then extracting the multivalue-field "child".

Now, here is what i am trying to solve now -- i would like to be able to fetch all the nodes
that match a certain criteria, if they are contained in some fragment of the tree. To visualize:

 +-> A
 |   +-> B
 |   +-> C
 |       +->D
 |       +->E

i would like to issue a query that gives me all the nodes within "A", a flat list of results
that contain B,C,D and E

Now, since per my definition D is not directly correlated with A (it knows his parent C, but
not that its also part of A -- only C knows that) , i was thinking of introducing a new field
for every node into my Lucene index that holds a list of IDs thats trace back to the root
element (in this case, the D node would have C and A in that field, in that order) - but it
strikes me this may not be the most elegant approach...

The above is only a simplified example, in reality, i have a tree about 10 levels deep, with
thousands of nodes, and i frequently need to surface nodes within a certain fragment of that

Is there any best practice that you ran into on how to map this elegantly into Lucene?

Thanks a ton for any pointers,
Emanuel Schleussinger

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message