<p dir="auto">In the presence of top level inner hits query level inner hits are missing from the result, even if there are no name collisions. This necessitates rewriting query level inner hits as top level inner hits with a duplicate of the main query, which I assume is suboptimal.</p>
<p dir="auto">ES 2.1.1.</p>
<p dir="auto">I have got an issue for few days and I have no idea how can I resolve it. I got no matching while percolating a document when obviously it should match a created percolator.</p>
<p dir="auto">Here is how to reproduce this issue:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#Create an index with a geo_point mapping as nested object
curl -XPUT 'http://localhost:9200/geonestedindex' -d '
{
   &quot;mappings&quot;:{
      &quot;test&quot;:{
         &quot;properties&quot;:{
            &quot;location&quot;:{
               &quot;type&quot;:&quot;nested&quot;,
               &quot;properties&quot;:{
                  &quot;point&quot;:{
                     &quot;type&quot;:&quot;geo_point&quot;
                  }
               }
            }
         }
      }
   }
}'"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span>Create an index with a geo_point mapping as nested object</span>
curl -XPUT <span class="pl-s"><span class="pl-pds">'</span>http://localhost:9200/geonestedindex<span class="pl-pds">'</span></span> -d <span class="pl-s"><span class="pl-pds">'</span></span>
<span class="pl-s">{</span>
<span class="pl-s">   "mappings":{</span>
<span class="pl-s">      "test":{</span>
<span class="pl-s">         "properties":{</span>
<span class="pl-s">            "location":{</span>
<span class="pl-s">               "type":"nested",</span>
<span class="pl-s">               "properties":{</span>
<span class="pl-s">                  "point":{</span>
<span class="pl-s">                     "type":"geo_point"</span>
<span class="pl-s">                  }</span>
<span class="pl-s">               }</span>
<span class="pl-s">            }</span>
<span class="pl-s">         }</span>
<span class="pl-s">      }</span>
<span class="pl-s">   }</span>
<span class="pl-s">}<span class="pl-pds">'</span></span></pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#Create a percolator

curl - XPOST 'http://localhost:9200/geonestedindex/.percolator/1' -d '
{
  &quot;query&quot;: {
    &quot;filtered&quot;: {
      &quot;query&quot;: {
        &quot;match_all&quot;: {}
      },
      &quot;filter&quot;: {
        &quot;nested&quot;: {
          &quot;filter&quot;: {
            &quot;geo_bbox&quot;: {
              &quot;point&quot;: {
                &quot;top_left&quot;: [
                  4.559326171875,
                  45.08127861241874
                ],
                &quot;bottom_right&quot;: [
                  5.2130126953125,
                  44.692088041727814
                ]
              }
            }
          },
          &quot;path&quot;: &quot;location&quot;
        }
      }
    }
  }
}'"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span>Create a percolator</span>

curl - XPOST <span class="pl-s"><span class="pl-pds">'</span>http://localhost:9200/geonestedindex/.percolator/1<span class="pl-pds">'</span></span> -d <span class="pl-s"><span class="pl-pds">'</span></span>
<span class="pl-s">{</span>
<span class="pl-s">  "query": {</span>
<span class="pl-s">    "filtered": {</span>
<span class="pl-s">      "query": {</span>
<span class="pl-s">        "match_all": {}</span>
<span class="pl-s">      },</span>
<span class="pl-s">      "filter": {</span>
<span class="pl-s">        "nested": {</span>
<span class="pl-s">          "filter": {</span>
<span class="pl-s">            "geo_bbox": {</span>
<span class="pl-s">              "point": {</span>
<span class="pl-s">                "top_left": [</span>
<span class="pl-s">                  4.559326171875,</span>
<span class="pl-s">                  45.08127861241874</span>
<span class="pl-s">                ],</span>
<span class="pl-s">                "bottom_right": [</span>
<span class="pl-s">                  5.2130126953125,</span>
<span class="pl-s">                  44.692088041727814</span>
<span class="pl-s">                ]</span>
<span class="pl-s">              }</span>
<span class="pl-s">            }</span>
<span class="pl-s">          },</span>
<span class="pl-s">          "path": "location"</span>
<span class="pl-s">        }</span>
<span class="pl-s">      }</span>
<span class="pl-s">    }</span>
<span class="pl-s">  }</span>
<span class="pl-s">}<span class="pl-pds">'</span></span></pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#Trying to match a document
curl -XPOST 'http://localhost:9200/geonestedindex/test/_percolate' -d '
{
  &quot;doc&quot;: {
    &quot;location&quot;: {
      &quot;point&quot;: &quot;44.933, 4.9&quot;
    }
  }
}'"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span>Trying to match a document</span>
curl -XPOST <span class="pl-s"><span class="pl-pds">'</span>http://localhost:9200/geonestedindex/test/_percolate<span class="pl-pds">'</span></span> -d <span class="pl-s"><span class="pl-pds">'</span></span>
<span class="pl-s">{</span>
<span class="pl-s">  "doc": {</span>
<span class="pl-s">    "location": {</span>
<span class="pl-s">      "point": "44.933, 4.9"</span>
<span class="pl-s">    }</span>
<span class="pl-s">  }</span>
<span class="pl-s">}<span class="pl-pds">'</span></span></pre></div>