Skip to content

has_child and inner_hits for grandchild hit doesn't work #11118

@lukens

Description

@lukens

I'm trying to get inner_hits to work on an a two level deep has_child 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.

Below is an example query:

{
  "from" : 0,
  "size" : 25,
  "query" : {
    "has_child" : {
      "query" : {
        "has_child" : {
          "query" : {
            "filtered" : {
              "query" : {
                "multi_match" : {
                  "query" : "asia",
                  "fields" : [ "_search" ],
                  "operator" : "AND",
                  "analyzer" : "library_synonyms",
                  "fuzziness" : "1"
                }
              },
              "filter" : {
                "and" : {
                  "filters" : [ {
                    "terms" : {
                      "range" : [ "Global" ]
                    }
                  } ]
                }
              }
            }
          },
          "child_type" : "document-ref",
          "inner_hits" : {
            "name" : "document-ref"
          }
        }
      },
      "child_type" : "class",
      "inner_hits" : {
        "size" : 1000,
        "_source" : false,
        "fielddata_fields" : [ "class" ],
        "name" : "class"
      }
    }
  },
  "fielddata_fields" : [ "name" ]
}

The document-ref 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?

Metadata

Metadata

Assignees

Labels

:Search/SearchSearch-related issues that do not fall into other categories>bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions