ElasticSearch Inner Hits on has_parent nested Inner hits

I've searched for this and haven't found anything that says whether this is or is not supported. According to Elastic documentation:

"Inner hits can be used by defining an inner_hits definition on a
nested, has_child or has_parent query and filter. "

I want to use inner_hits on a has_parent, nested object. I've tried it as illustrated in the example below. Does anyone know if this is possible?

Example Scenario (I've simplified the data and properties for the purpose of this post)

We store task title & description translations as a nested object in
the parent task. Each nested title has an iso code and a translated
title & description. We distribute child tasks to, in some cases,
thousands of users so it didn't make sense replicating the
title/description into each child object.

Parent Task Example

    {
      "_id": "parenttask_177448",
      "startDate": "2020-05-01T00:00:00",
      "endDate": "2020-05-05T00:00:00",
      "type": "task",
      "taskjoin" : "parenttask",
      "priorityId": 1,
      "translations": [
        {
          "title": "This is a test task",
          "description": "test",
          "localeIsoCode": [
            "en-US"
          ]
        },
        {
          "description": "tester",
          "title": "Ceci est une tâche de test",
          "localeIsoCode": [
            "fr-FR"
          ]
        }
      ]
    }

Children Task(s) Example

    {
        "_id": "childtask_12345",
        "taskSubType": "distributed",
        "subtasks": [],
        "startDate": "2020-03-19T00:00:00",
        "endDate": "2020-03-19T00:00:00",
        "taskJoinField": {
          "name": "taskjoin",
          "parent": "parenttask_177448"
        },
        "assignedUserId": 12345,
        "assignedUserName": "Bob Jones"
    }

Relevant part of the query I'm running that brings back no inner hits results

    {
      "has_parent": {
        "ignore_unmapped": true,
        "parent_type": "parenttask",
        "query": {
          "nested": {
            "ignore_unmapped": true,
            "inner_hits": {
              "name": "innerhits_task",
              "_source": {
                "includes": [
                  "title"
                ]
              }
            },
            "path": "translations",
            "query": {
              "term": {
                "translations.localeIsoCode.keyword": {
                  "value": "fr-FR"
                }
              }
            },
            "boost": 1.1,
            "_name": "nested_isocode"
          }
        },
        "score": true,
        "boost": 1.1,
        "_name": "parent_isocode"
      }
    }

I'm getting results back from the child tasks but no inner hits matches. If I move the inner hits to the has_parent, I get all the translations back.

My question is whether doing a parent nested inner hits is possible in Elastic? I'm surprised I didn't find anyone else trying to do this or examples on the Internet. This seems like a pretty common use case.

Posted the same question to StackOverflow. I hope that is Ok. This is my first post to elastic.co.

Thanks for your help.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.