# See which of the nested objects matched the nested filter?

**URL:** https://discuss.elastic.co/t/see-which-of-the-nested-objects-matched-the-nested-filter/232663
**Category:** Elasticsearch
**Created:** [May 14, 2020, 1:59pm UTC](https://discuss.elastic.co/t/see-which-of-the-nested-objects-matched-the-nested-filter/232663 "2020-05-14T13:59:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![johnc1](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@johnc1](https://discuss.elastic.co/u/johnc1)
#### Post date: [May 14, 2020, 1:59pm UTC](https://discuss.elastic.co/t/see-which-of-the-nested-objects-matched-the-nested-filter/232663/1 "2020-05-14T13:59:22Z")

</div>

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:

```json
{
  "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?

---

<div class="post-metadata">

### Author: ![johnc1](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@johnc1](https://discuss.elastic.co/u/johnc1)
#### Post date: [May 16, 2020, 6:57pm UTC](https://discuss.elastic.co/t/see-which-of-the-nested-objects-matched-the-nested-filter/232663/2 "2020-05-16T18:57:45Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 13, 2020, 6:57pm UTC](https://discuss.elastic.co/t/see-which-of-the-nested-objects-matched-the-nested-filter/232663/3 "2020-06-13T18:57:47Z")

</div>

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