0

Instead of storing a flat structure, I have tree structure to store in lucene index. While doing a search on tree, I have to return search node as well as all ancestor of that node.

For ex, tree is like below. Its complete geography tree.

      Global
      |    |
     Asia North America
     |     |        |
 China    USA      MEXICO

I can think of two ways to store this data in lucene.

1st approach: Capture on parent node of a given node.
       name, parent
       Asia, Global
       China, Asia
       USA, North America

Java Object:
Class Node
     id ,name

In this approach, lets say I am searching for USA. As per requirement I have to return all ancestors of USA which North America and Global. So I have to do go index in recursive manner.

2nd approach: store ancestors in lucene index also

Java Object:    
    class Node
    id, name, List<Node> ancestors

In this approach, I am capturing ancestors multiple times. Will it create an issue or lucene captures the duplicate values only once ?

Which approach would be better or is there a another good to store tree kind of structure in lucene ?

Thanks.

user3222372
  • 352
  • 3
  • 20
  • Possible duplicate of [How to store tree data in a Lucene/Solr/Elasticsearch index or a NoSQL db?](http://stackoverflow.com/questions/9970193/how-to-store-tree-data-in-a-lucene-solr-elasticsearch-index-or-a-nosql-db) – Sabir Khan Oct 09 '16 at 07:15
  • The solutions in link caters to multiple tree in lucene. I have only one tree. – user3222372 Oct 14 '16 at 19:46

0 Answers0