title: Can I use parent-child relationships on Kibana?
body: <p>On a relational DB, I have two tables connected by a foreign key, on a typical one-to-many relationship. I would like to translate this schema into ElasticSearch, so I researched and found two options: the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/1.3/mapping-nested-type.html" rel="noreferrer">nested</a> and <a href="https://www.elastic.co/guide/en/elasticsearch" rel="noreferrer">parent-child</a>. My ultimate goal was to visualize this dataset in Kibana 4.</p>
  
  <p>Parent-child seemed the most adequate one, so I'll describe the steps that I followed, based on the official <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html" rel="noreferrer">ES documentation</a> and a few examples I found on the web.</p>
  
  <pre><code> curl  -XPUT http://server:port/accident_struct -d '
  {
   "mappings" : {
    "event" : {
    },
    "details": {
        "_parent": {
          "type": "event" 
        } ,
     "properties" : {       
   }  
    }
   }
  }
  ';
  </code></pre>
  
  <p>here I create the index accident_struct, which contains two types (corresponding to the two relational tables): event and details.</p>
  
  <p>Event is the parent, thus each document of details has an event associated to it.</p>
  
  <p>Then I upload the documents using the bulk API. For event:</p>
  
  <pre><code>{"index":{"_index":"accident_struct","_type":"event","_id":"17f14c32-53ca-4671-b959-cf47e81cf55c"}}
  {values here...}
  </code></pre>
  
  <p>And for details:</p>
  
  <pre><code>{"index":{"_index":"accident_struct","_type":"details","_id": "1", "_parent": "039c7e18-a24f-402d-b2c8-e5d36b8ad220" }}
  </code></pre>
  
  <p>The event does not know anything about children, but each child (details) needs to set its parent. In the ES documentation I see the parent being set using "parent", while in other examples I see it using "_parent". I wonder what is the correct option (although at this point, none works for me).</p>
  
  <p>The requests are successfully completed and I can see that the number of documents contained in the index corresponds to the sum of events + types. </p>
  
  <p>I can also query parents for children and children for parents, on ES. For example:</p>
  
  <pre><code>curl -XPOST host:port/accident_struct/details/_search?pretty -d '{
      "query" : {
          "has_parent" : {
              "type" : "event",
                  "query" : {
                      "match_all" : {}
                  }
          }
      }
  }'
  </code></pre>
  
  <p>After setting the index on Kibana, I am able to list all the fields from parent and child. However, if I go to the "discover" tab, only the parent fields are listed.</p>
  
  <p>If I uncheck a box that reads "hide missing fields", the fields from the child documents are shown as grey out, along with an error message (see image)</p>
  
  <p><img src="https://i.stack.imgur.com/JjVl9.png" alt="enter image description here"></p>
  
  <p>Am I doing something wrong or is the parent-child not supported in Kibana4? And if it is not supported, what would be the best alternative to represent this type of relationship?</p>