# Search documents by unmapped fields for debugging

**URL:** <https://discuss.elastic.co/t/search-documents-by-unmapped-fields-for-debugging/275055>\
**Category:** Elasticsearch\
**Created:** [June 6, 2021, 7:43am UTC](https://discuss.elastic.co/t/search-documents-by-unmapped-fields-for-debugging/275055 "2021-06-06T07:43:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Metheny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/metheny/32/102517_2.png) [@Metheny](https://discuss.elastic.co/u/Metheny)\
**Post date:** [June 6, 2021, 7:43am UTC](https://discuss.elastic.co/t/search-documents-by-unmapped-fields-for-debugging/275055/1 "2021-06-06T07:43:25Z")

</div>

We are using fixed (non dynamic) mapping in our indices in order to improve performance.  
The mapping contains a subset of our document fields, and the rest of the fields are unmapped.  
However, for debugging purposes we sometimes need to filter/count/sort documents in Kibana according to unmapped fields. It could be any unmapped field, and not specific ones.  
For this debugging purpose performance is not important, we just need to be able to do it.

I thought it may be possible to achieve this by using scripts somehow, but haven't found any way to do this in the documentation or in anywhere else.  
The only way we found is to write a client script that gets all documents and does the logic.

Is there anyway to do this using DSL ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 7, 2021, 6:07am UTC](https://discuss.elastic.co/t/search-documents-by-unmapped-fields-for-debugging/275055/2 "2021-06-07T06:07:14Z")

</div>

> [@Metheny](#):
>
> The mapping contains a subset of our document fields, and the rest of the fields are unmapped.

Can you please elaborate more on what you mean by unmapped here.

---

<div class="post-metadata">

**Author:** ![Metheny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/metheny/32/102517_2.png) [@Metheny](https://discuss.elastic.co/u/Metheny)\
**Post date:** [June 8, 2021, 2:26pm UTC](https://discuss.elastic.co/t/search-documents-by-unmapped-fields-for-debugging/275055/3 "2021-06-08T14:26:48Z")

</div>

> Can you please elaborate more on what you mean by unmapped here.

Meaning fields that weren't included when defining the index mapping, but exists in the document itself. I'm talking about a case of non-dynamic mapping.  
In the following example we won't be able to search documents according to the field `other_field`. Again, we need this only for manually debugging our production database but our backend itself doesn't attempt to search by non-mapped fields.

```auto
PUT /test
{
  "mappings": {
    "dynamic" : "false",
    "properties": {
      "mapped_field": { "type": "text" }
    }
  }
}

POST test/_doc/
{
  "mapped_field": "this is mapped",
  "other_field": "this is unmapped since it is not included in the index mapping"
}

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 8, 2021, 10:07pm UTC](https://discuss.elastic.co/t/search-documents-by-unmapped-fields-for-debugging/275055/4 "2021-06-08T22:07:29Z")

</div>

There's no way to do what you want here unless you stop using `"dynamic" : "false",`.

---

<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:** [July 6, 2021, 10:07pm UTC](https://discuss.elastic.co/t/search-documents-by-unmapped-fields-for-debugging/275055/5 "2021-07-06T22:07:49Z")

</div>

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