Nested path with inner_hits and complex logical operations

I have document with following nested mapping ->
A -> B -> C

While querying with following expression with inner_hits to get matching part of the document ->

((A.B.field1 == 1) AND (A.B.C.field2 == "Foo")) OR ((A.B.field1 == 3) AND (A.B.C.field2 == "Bar"))

"query": {
  "bool": {
    "filter": {
      "nested": {
        "inner_hits": {},
          "path": "A",
            "query": {
               "bool": {
                 "filter": {
                    "nested": {
                      "inner_hits": {},
                       "path": "B",
                       "query": {
                         "bool": {
                           "minimum_should_match": 1,
                           "should": [
                              {
                               "bool": {
                                 "must":[
                                   {
                                     {
                                       "bool": { "must": ["bool": {"filter": ["match": {A.B.field1: 1}]}]}
                                     },
                                    {
                                      "bool": { "filter": [{"nested": {"path": "A.B.C", inner_hits:{"name":"A.B.C.1"},"query": {"match":{A.B.C.field2: "Foo"}}}}]}
                                    }
                                  }
                                ]
                              }
                            },
                            {
                               "bool": {
                                 "must":[
                                   {
                                     {
                                       "bool": { "must": ["bool": {"filter": ["match": {A.B.field1: 3}]}]}
                                     },
                                    {
                                      "bool": { "filter": [{"nested": {"path": "A.B.C", inner_hits:{"name":"A.B.C.2"},"query": {"match":{A.B.C.field2: "Bar"}}}}]}
                                    }
                                  }
                                ]
                              }
                            },
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }

This returns response with inner_hits matching conditions A.B.C.field2 == "Foo" and A.B.C.field2 == "Bar" individually, i.e. without considering other conditions in the logical expression.
I need a programatic way to process the response to join the matching pieces (i.e. matching pieces for each of the nesting level). But, because inner_hits "A.B.C.1" and "A.B.C.2" contains information which doesn't always fulfil the entire matching criteria, it is non-trivial to decide which inner_hit to consider.
Is there anyway to for all the inner_hits to include part of the document which matches entire logical expression? (matching part of that nesting level, and entire sub-nesting below as is)
This used to be the behaviour in some of the older versions without fix for https://github.com/elastic/elasticsearch/pull/37645

This used to work say in 6.6.0, but not working in 6.7.1 onwards...

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