title: Storing nested objects in elastic search
body: <p>I have a 3 level nested object something like below, I want to index these objects in elastic search. Requirement here is users will write a search query keywords like "keyword1 keyword2 ..." and I want to return objects that has all of these keywords in it (at any level i.e. AND operation). </p>
  
  <pre><code>   [  
     {  
        "country":[  
           {  
              "name":"India",
              "ext_code":"91",
              "states":[  
                 {  
                    "name":"Karnataka",
                    "ext_code":"04",
                    "cities":[  
                       {  
                          "name":"Bangalore",
                          "ext_code":"080"
                       }
                    ]
                 }
              ]
           }
        ]
     }
  ]
  </code></pre>
  
  <p>Currently, I store them in nested format using the following mapping:</p>
  
  <pre><code>{
      "mappings":{
          "doc":{
              "properties":{
                  "name": {"type":"text"},
                  "ext_code": {"type":"text"}
                  "state" {
                      "type": "nested",
                      "properties": {
                          "name": {"type":"text"},
                          "ext_code": {"type":"text"}
                          "city" {
                              "type": "nested",
                              "properties": {
                                  "name": {"type":"text"}
                                  "ext_code": {"type":"text"}
                              }
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>And while searching, I pass elastic search a nested query to search on all levels like below:</p>
  
  <pre><code>{
      "query": {
          "bool": {
              "should": [
                  {
                      "multi_match": {
                          "query": "keyword1 keyword2 ...",
                          "fields": ['name'] 
                      }
                  },
                  {
                      "nested": {
                          "path": 'state',
                          "query": {
                              "multi_match": {
                                  "query": "keyword1 keyword2 ...",
                                  "fields": ['state.name']
                              }
                          }
                      }
                  },
                  {
                      "nested": {
                          "path": 'state.city',
                          "query": {
                              "multi_match": {
                                  "query": "keyword1 keyword2 ...",
                                  "fields": ['state.city.name']
                              }
                          }
                      }
                  }
              ]
          }
      }
  }
  </code></pre>
  
  <p>When sending multiple tokens to search, it applies an OR operation returning documents containing any of the search tokens.</p>
  
  <p>Is there a way to configure Elastic Search to perform an AND operation for multiple tokens in search query? </p>