<p dir="auto">Enable a filtered query to apply filter to both parent and child documents but return parent documents for has_child query.</p>
<p dir="auto">e.g.<br>
curl -X PUT "<a href="http://localhost:9200/foobar" rel="nofollow">http://localhost:9200/foobar</a>" -d "{"mappings":{"Foo":{},"Bar":{"_parent":{"type":"Foo"}}}}"</p>
<p dir="auto">curl -X PUT "<a href="http://localhost:9200/foobar/Foo/1" rel="nofollow">http://localhost:9200/foobar/Foo/1</a>" -d "{"foo":"abc","access":"yes"}"</p>
<p dir="auto">curl -X PUT "<a href="http://localhost:9200/foobar/Bar/2?parent=1" rel="nofollow">http://localhost:9200/foobar/Bar/2?parent=1</a>" -d "{"bar":"xyz","access":"no"}"</p>
<p dir="auto">The following filtered query would not return a result, since the filter would be applied to both the parent and child documents; however, as implemented now, the parent document would be returned, since the filter is not applied to the child document.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
   &quot;query&quot;: {
      &quot;filtered&quot;: {
         &quot;query&quot;: {
            &quot;has_child&quot;: {
               &quot;type&quot;: &quot;Bar&quot;,
               &quot;query&quot;: {
                  &quot;term&quot;: {
                     &quot;bar&quot;: &quot;xyz&quot;
                  }
               }
            }
         },
         &quot;filter&quot;: {
            &quot;term&quot;: {
               &quot;access&quot;: &quot;yes&quot;
            }
         }
      }
   }
}"><pre class="notranslate"><code class="notranslate">{
   "query": {
      "filtered": {
         "query": {
            "has_child": {
               "type": "Bar",
               "query": {
                  "term": {
                     "bar": "xyz"
                  }
               }
            }
         },
         "filter": {
            "term": {
               "access": "yes"
            }
         }
      }
   }
}
</code></pre></div>
<p dir="auto">Perhaps an additional filtered_query strategy could be specified which would apply the filter first to both parent and child documents.</p>
<p dir="auto">this issue is based on the thread at location<br>
<a href="https://groups.google.com/forum/?hl=en&amp;fromgroups#!topic/elasticsearch/VCwQoZ1Aj4I" rel="nofollow">https://groups.google.com/forum/?hl=en&amp;fromgroups#!topic/elasticsearch/VCwQoZ1Aj4I</a></p>
<p dir="auto">requesting to allow using update API (using scripts) in bulk via the bulk request API.</p>