title: Multi Level Nested Queries
body: <p>I have a multi-level nested document. I want to query based on multiple nested queries with all the conditions must match.</p>
  
  <p>Example</p>
  
  <p>Document 1</p>
  
  <pre><code>{
      "publishing_rule": {
          "publishing_orders": [{
                  "transporters": [{
                      "fteid": "81"
                  }],
                  "active": false
              },
              {
                  "transporters": [{
                      "fteid": "82"
                  }],
                  "active": true
              }
          ]
      }
  }
  </code></pre>
  
  <p>Document 2</p>
  
  <pre><code>{
      "publishing_rule": {
          "publishing_orders": [{
                  "transporters": [{
                      "fteid": "81"
                  }],
                  "active": true
              },
              {
                  "transporters": [{
                      "fteid": "82"
                  }],
                  "active": false
              }
          ]
      }
  }
  </code></pre>
  
  <p>I want to fetch all the documents which match below condition</p>
  
  <pre><code>publishing_rule.publishing_orders.active = true 
  
  AND 
  
  publishing_rule.publishing_orders.transporters.fteid = '81'
  </code></pre>
  
  <p>Both <code>active</code> and <code>transporters.fteid</code> should be part of same object.</p>
  
  <p>I have tried creating below mapping</p>
  
  <pre><code>{
    "mappings": {
      "_doc": {
        "properties": {
          "publishing_rule.publishing_orders": {
            "type": "nested",
            "properties": {
              "transporters": {
                "type": "nested"
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>And used below query </p>
  
  <pre><code>{
    "query": {
      "bool": {
        "must": [
          {
            "nested": {
              "path": "publishing_rule.publishing_orders",
              "query": {
                "bool": {
                  "must": [
                    {
                      "match": {
                        "publishing_rule.publishing_orders.active": true
                      }
                    }
                  ]
                }
              }
            }
          },
          {
            "nested": {
              "path": "publishing_rule.publishing_orders.transporters",
              "query": {
                "bool": {
                  "must": [
                    {
                      "match": {
                        "publishing_rule.publishing_orders.transporters.fteid": "81"
                      }
                    }
                  ]
                }
              }
            }
          }
        ]
      }
    }
  }
  </code></pre>
  
  <p>But I am not getting expected result. The query returning both the documents. </p>
  
  <p>I am expecting only Document 2 in the result.</p>