title: Elastic search deep tree model
body: <p>I’m researching for database tool, and i’m not quite sure how Elastic can cope with my requirements.</p>
  
  <p>I have a tree data structure, a family tree.</p>
  
  <p>The root is the first man Adam, and afterward his children, there children and so on.</p>
  
  <p>Elements looks like this (don't care about marriage relations this data just to get the idea) :</p>
  
  <pre><code>{
    id: 1
    name: “Adam”
    parentId: 0
  }, {
    id: 2
    name: “Cain”
    parentId: 1
  }, {
    id: 3
    name: “Abel”
    parentId: 1
  }, {
    id: 4
    name: “johnny(Cain junior)”
    parentId: 2
  }, … {
    id: 12324568
    name: “Cain b”
    parentId: 1434
  }
  </code></pre>
  
  <p>Queries I’d like to exec:</p>
  
  <ol>
  <li><p>‘full text’ search on the element name, response should include the documents and the path to them. Fof example, searching for ‘Cain’ should replay:</p>
  
  <p>a. Adam/Cain </p>
  
  <p>b.  ../David/Danny/Cain b</p></li>
  <li><p>CRUD person by id (Ids are unique)</p></li>
  <li><p>Get family tree by id, will respond hierarchical tree (nested JSON) , from ‘id’ as root</p></li>
  <li><p>Tree is about ~20-30 level deep, up to 10,000 elements</p></li>
  </ol>
  
  <p>Finally, my question:  </p>
  
  <ol>
  <li><p>Can elasticsearch provide me this functionality?</p></li>
  <li><p>Should i use the parent/child scheme?</p></li>
  <li><p>How should the index mapping should look.   </p></li>
  </ol>