title: Elasticsearch filter only inner data
body: <p>I am new to ES, I have an index has a nested type</p>
  <pre><code>{
      &quot;mappings&quot;: {
          &quot;product&quot;: {
              &quot;properties&quot;: {
                  &quot;productid&quot;: {
                      &quot;type&quot;: &quot;integer&quot;
                  },
                  &quot;description&quot;: {
                    &quot;type&quot;: &quot;text&quot;
                  },
                  &quot;inventory&quot;: {
                      &quot;type&quot;: &quot;nested&quot;,
                      &quot;properties&quot;: {
                          &quot;location&quot;: {
                              &quot;type&quot;: &quot;integer&quot;
                          },
                          &quot;productvalue&quot;: {
                              &quot;type&quot;: &quot;double&quot;
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  <p>I have inserted following 2 products in this:</p>
  <pre><code>POST productlist/product/1
  {
      &quot;productid&quot;: 1,
              &quot;description&quot;: &quot;rose red&quot;,
      &quot;inventory&quot;: [
          {
              &quot;location&quot;: 1,
              &quot;productvalue&quot;: 100
          },
          {
              &quot;branch&quot;: 2,
              &quot;onhand&quot;: 50
          }
      ]
  }
  
  POST productlist/product/2
  {
      &quot;productid&quot;: 2,
              &quot;description&quot;: &quot;rose purple&quot;,
      &quot;inventory&quot;: [
          {
              &quot;branch&quot;: 1,
              &quot;onhand&quot;: 1000
          },
          {
              &quot;branch&quot;: 3,
              &quot;onhand&quot;: 500
          }
      ]
  }
  </code></pre>
  <p>I have a sample query as below:</p>
  <pre><code>{
      &quot;query&quot;: {
          &quot;bool&quot;: {
              &quot;must&quot;: [
                  {
                      &quot;multi_match&quot;: {
                          &quot;fields&quot;: [
                              &quot;description&quot;
                          ],
                          &quot;minimum_should_match&quot;: &quot;75%&quot;,
                          &quot;operator&quot;: &quot;and&quot;,
                          &quot;query&quot;: &quot;rose&quot;,
                          &quot;type&quot;: &quot;phrase_prefix&quot;
                      }
                  },
                  {
                      &quot;nested&quot;: {
                          &quot;path&quot;: &quot;inventory&quot;,
                          &quot;query&quot;: {
                              &quot;term&quot;: {
                                  &quot;inventory.branch&quot;: &quot;1&quot;
                              }
                          },
                          &quot;inner_hits&quot;: {}
                      }
                  }
              ]
          }
      }
  }
  </code></pre>
  <p>This query returns me both my records with the nested inventory object having 2 records each. I want to get both the main product records but in each inventory record I want to get only the value for location 1 and no other location.
  How can this be achieved?
  Thanks</p>