# Unable to search for flattened (nested) field existence

**URL:** <https://discuss.elastic.co/t/unable-to-search-for-flattened-nested-field-existence/315863>\
**Category:** Elasticsearch\
**Created:** [October 5, 2022, 10:47am UTC](https://discuss.elastic.co/t/unable-to-search-for-flattened-nested-field-existence/315863 "2022-10-05T10:47:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruslaniv](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@ruslaniv](https://discuss.elastic.co/u/ruslaniv)\
**Post date:** [October 5, 2022, 10:47am UTC](https://discuss.elastic.co/t/unable-to-search-for-flattened-nested-field-existence/315863/1 "2022-10-05T10:47:51Z")

</div>

I'm storing an arbitrary nested object as a flattened field "\_meta" which contains various information related to a product.  
Here is the mapping for that field:

```auto
"mappings": {
        "dynamic": "strict",
        "properties": {
            "_meta": {
                "type": "flattened"
            },
            ...

```

So when trying to search for:

```auto
{
    "query": {
        "exists": {
            "field": "_meta.user"
        }
    }
}

```

I'm expecting to retrieve all documents that have that field populated. I get zero hits, although if I search for a particular document, I can see that at least one document has that field populated:

```auto
"user": {
  "origin_title": "some title",
  "origin_title_en": "some other title",
  "address": "some address",
  "performed_orders_count": 0,
  "phone": "some phone",
  "name": "some name",
  "tariff": null,
  "proposal_image_background_color": null
},

```

So how exactly does searching through a flattened data field work?  
Why I'm not getting any results?

---

<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:** [November 2, 2022, 10:48am UTC](https://discuss.elastic.co/t/unable-to-search-for-flattened-nested-field-existence/315863/2 "2022-11-02T10:48:41Z")

</div>

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