# Elasticsearch keeps indexing nested fields as text

**URL:** <https://discuss.elastic.co/t/elasticsearch-keeps-indexing-nested-fields-as-text/135543>\
**Category:** Elasticsearch\
**Created:** [June 12, 2018, 1:17pm UTC](https://discuss.elastic.co/t/elasticsearch-keeps-indexing-nested-fields-as-text/135543 "2018-06-12T13:17:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mugen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mugen/32/16454_2.png) [@Mugen](https://discuss.elastic.co/u/Mugen)\
**Post date:** [June 12, 2018, 1:17pm UTC](https://discuss.elastic.co/t/elasticsearch-keeps-indexing-nested-fields-as-text/135543/1 "2018-06-12T13:17:36Z")

</div>

I've got some terribly nested log messages in JSON format. Somehow elasticsearch keeps mapping one of the field as text eventough it contains several subfields. Is there something wrong with my mapping ?

Message in Kibana:

 ![Kibana](https://us1.discourse-cdn.com/elastic/original/3X/a/9/a97bd2c5dc0e4459b7f3013c4f4d0c93180b74ce.png)

Message as JSON (in Kibana)

![json](https://us1.discourse-cdn.com/elastic/original/3X/4/f/4fb26f2966388f9036b7385f7ab70d252802640e.png)

```auto
{
    "index_patterns": "azure-*",
    "version": 0,
    "mappings": {
        "doc": {
            "properties": { 
                "records": {
                    "type": "nested",
                    "properties": {
                        "requestbody": {
                            "properties": {
                                "properties": {
                                    "properties": {
                                        "encryption": {
                                            "properties": {
                                                "keySource": {
                                                    "type": "keyword"
                                                },
                                                "keyvaultproperties": {
                                                    "properties": {
                                                        "keyversion": {
                                                            "type": "keyword"
                                                        },
                                                        "keyname": {
                                                            "type": "keyword"
                                                        },
                                                        "keyvaulturi": {
                                                            "type": "keyword"
                                                        }
                                                    }
                                                },
                                                "services" : {
                                                    "properties":{
                                                        "blob" : {
                                                            "properties": {
                                                                "enabled":{
                                                            "type": "boolean"
                                                        }}},
                                                        "file" : {
                                                            "properties": {
                                                                "enabled":{
                                                            "type": "boolean"
                                                        }}}
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },

```

---

<div class="post-metadata">

**Author:** ![Mugen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mugen/32/16454_2.png) [@Mugen](https://discuss.elastic.co/u/Mugen)\
**Post date:** [June 12, 2018, 1:39pm UTC](https://discuss.elastic.co/t/elasticsearch-keeps-indexing-nested-fields-as-text/135543/2 "2018-06-12T13:39:41Z")

</div>

Another problem is, that fields like **records.minimum** aren't filterable.  
As soon as I create "exists" filter. Kibana says there are no documents.

---

<div class="post-metadata">

**Author:** ![Mugen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mugen/32/16454_2.png) [@Mugen](https://discuss.elastic.co/u/Mugen)\
**Post date:** [June 12, 2018, 3:03pm UTC](https://discuss.elastic.co/t/elasticsearch-keeps-indexing-nested-fields-as-text/135543/3 "2018-06-12T15:03:35Z")

</div>

Solved the problem. I deleted my index template. Indexed my data and used the automatically generated mapping as a template. Hope this helps some of you. Wish I would have thought of this earlier. 🙂

---

<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 10, 2018, 3:03pm UTC](https://discuss.elastic.co/t/elasticsearch-keeps-indexing-nested-fields-as-text/135543/4 "2018-07-10T15:03:40Z")

</div>

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