<p dir="auto">.</p>
<p dir="auto">I'm trying to get <code class="notranslate">inner_hits</code> to work on an a two level deep <code class="notranslate">has_child</code> query, but the grandchild hits just seem to return an empty array.  If I specify the inner hits at the top level I get the results I want, but its rather too slow. Using inner hits on the has child query seems much faster, but doesn't return the grandchild hits.</p>
<p dir="auto">Below is an example query:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;from&quot; : 0,
  &quot;size&quot; : 25,
  &quot;query&quot; : {
    &quot;has_child&quot; : {
      &quot;query&quot; : {
        &quot;has_child&quot; : {
          &quot;query&quot; : {
            &quot;filtered&quot; : {
              &quot;query&quot; : {
                &quot;multi_match&quot; : {
                  &quot;query&quot; : &quot;asia&quot;,
                  &quot;fields&quot; : [ &quot;_search&quot; ],
                  &quot;operator&quot; : &quot;AND&quot;,
                  &quot;analyzer&quot; : &quot;library_synonyms&quot;,
                  &quot;fuzziness&quot; : &quot;1&quot;
                }
              },
              &quot;filter&quot; : {
                &quot;and&quot; : {
                  &quot;filters&quot; : [ {
                    &quot;terms&quot; : {
                      &quot;range&quot; : [ &quot;Global&quot; ]
                    }
                  } ]
                }
              }
            }
          },
          &quot;child_type&quot; : &quot;document-ref&quot;,
          &quot;inner_hits&quot; : {
            &quot;name&quot; : &quot;document-ref&quot;
          }
        }
      },
      &quot;child_type&quot; : &quot;class&quot;,
      &quot;inner_hits&quot; : {
        &quot;size&quot; : 1000,
        &quot;_source&quot; : false,
        &quot;fielddata_fields&quot; : [ &quot;class&quot; ],
        &quot;name&quot; : &quot;class&quot;
      }
    }
  },
  &quot;fielddata_fields&quot; : [ &quot;name&quot; ]
}"><pre class="notranslate">{
  <span class="pl-ent">"from"</span> : <span class="pl-c1">0</span>,
  <span class="pl-ent">"size"</span> : <span class="pl-c1">25</span>,
  <span class="pl-ent">"query"</span> : {
    <span class="pl-ent">"has_child"</span> : {
      <span class="pl-ent">"query"</span> : {
        <span class="pl-ent">"has_child"</span> : {
          <span class="pl-ent">"query"</span> : {
            <span class="pl-ent">"filtered"</span> : {
              <span class="pl-ent">"query"</span> : {
                <span class="pl-ent">"multi_match"</span> : {
                  <span class="pl-ent">"query"</span> : <span class="pl-s"><span class="pl-pds">"</span>asia<span class="pl-pds">"</span></span>,
                  <span class="pl-ent">"fields"</span> : [ <span class="pl-s"><span class="pl-pds">"</span>_search<span class="pl-pds">"</span></span> ],
                  <span class="pl-ent">"operator"</span> : <span class="pl-s"><span class="pl-pds">"</span>AND<span class="pl-pds">"</span></span>,
                  <span class="pl-ent">"analyzer"</span> : <span class="pl-s"><span class="pl-pds">"</span>library_synonyms<span class="pl-pds">"</span></span>,
                  <span class="pl-ent">"fuzziness"</span> : <span class="pl-s"><span class="pl-pds">"</span>1<span class="pl-pds">"</span></span>
                }
              },
              <span class="pl-ent">"filter"</span> : {
                <span class="pl-ent">"and"</span> : {
                  <span class="pl-ent">"filters"</span> : [ {
                    <span class="pl-ent">"terms"</span> : {
                      <span class="pl-ent">"range"</span> : [ <span class="pl-s"><span class="pl-pds">"</span>Global<span class="pl-pds">"</span></span> ]
                    }
                  } ]
                }
              }
            }
          },
          <span class="pl-ent">"child_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>document-ref<span class="pl-pds">"</span></span>,
          <span class="pl-ent">"inner_hits"</span> : {
            <span class="pl-ent">"name"</span> : <span class="pl-s"><span class="pl-pds">"</span>document-ref<span class="pl-pds">"</span></span>
          }
        }
      },
      <span class="pl-ent">"child_type"</span> : <span class="pl-s"><span class="pl-pds">"</span>class<span class="pl-pds">"</span></span>,
      <span class="pl-ent">"inner_hits"</span> : {
        <span class="pl-ent">"size"</span> : <span class="pl-c1">1000</span>,
        <span class="pl-ent">"_source"</span> : <span class="pl-c1">false</span>,
        <span class="pl-ent">"fielddata_fields"</span> : [ <span class="pl-s"><span class="pl-pds">"</span>class<span class="pl-pds">"</span></span> ],
        <span class="pl-ent">"name"</span> : <span class="pl-s"><span class="pl-pds">"</span>class<span class="pl-pds">"</span></span>
      }
    }
  },
  <span class="pl-ent">"fielddata_fields"</span> : [ <span class="pl-s"><span class="pl-pds">"</span>name<span class="pl-pds">"</span></span> ]
}</pre></div>
<p dir="auto">The <code class="notranslate">document-ref</code> inner hits just always returns an empty array.  Should this work (and, if so, any ideas why it isn't?), or is it beyond the means of what inner hits can currently do?</p>