See which of the nested objects matched the nested filter?

When I use "nested" query, is it possible to somehow see which specific nested objects matched the query? E.g., suppose I have Streets nested under City, and I run a query:

{
  "query": {
    "nested": {
      "path": "streets",
      "query": {
        "wildcard": {
          "streets.name": { "value": "*market*" }
        }
      }
    }
  }
}

The query gives me cities that have a street matching *market*. Is it possible to also get the name and the id of the street that matched for each of the returned cities?

After doing some more research on this, it seems to me it's not possible using existing ES API. I wonder if it's by design due to computational complexity concerns, or is it just missing functionality that perhaps I can implement myself? To me, it sounds like the "nested" query simply needs to record the identify of the object that matched the query and pass it upwards.

I'd appreciate any suggestion on that or any starting points on where to look in the source code?

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