# Map date as text?

**URL:** <https://discuss.elastic.co/t/map-date-as-text/121375>\
**Category:** Elasticsearch\
**Created:** [February 25, 2018, 12:17pm UTC](https://discuss.elastic.co/t/map-date-as-text/121375 "2018-02-25T12:17:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yassinelaz](https://avatars.discourse-cdn.com/v4/letter/y/22d042/32.png) [@yassinelaz](https://discuss.elastic.co/u/yassinelaz)\
**Post date:** [February 25, 2018, 12:17pm UTC](https://discuss.elastic.co/t/map-date-as-text/121375/1 "2018-02-25T12:17:12Z")

</div>

I have json data that has a "product\_ref" field (mapped as text) that can take these values as an example:

"product\_ref": "N/A"  
"product\_ref": "90323"  
"product\_ref": "SN3005"  
"product\_ref": "2015-05-23"

When pushing the data to the index i get a mapping error:

{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"mapper [root.product\_ref] of different type, current\_type [date], merged\_type [text]"}],"type":"illegal\_argument\_exception","reason":"mapper [root.product\_ref] of different type, current\_type [date], merged\_type [text]"},"status":400}

How to fix this?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 25, 2018, 2:22pm UTC](https://discuss.elastic.co/t/map-date-as-text/121375/2 "2018-02-25T14:22:24Z")

</div>

Set the mapping before indexing the first document.

---

<div class="post-metadata">

**Author:** ![yassinelaz](https://avatars.discourse-cdn.com/v4/letter/y/22d042/32.png) [@yassinelaz](https://discuss.elastic.co/u/yassinelaz)\
**Post date:** [February 25, 2018, 2:55pm UTC](https://discuss.elastic.co/t/map-date-as-text/121375/3 "2018-02-25T14:55:57Z")

</div>

If already set the mapping as follows:

```
{
    "mappings" : {
        "root" : {
            "properties" : {
                "product_seller" : {
                    "type" : "text"
                },
                "product_category" : {
                    "type" : "text"
                },
                "product_name" : {
                    "type" : "text"
                },
                "product_ref" : {
                    "type" : "text"
                },
                "product_brand" : {
                    "type" : "text"
                },
                "product_price" : {
                    "type" : "long"
                },
                "product_link" : {
                    "type" : "text"
                }
            }
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 25, 2018, 4:34pm UTC](https://discuss.elastic.co/t/map-date-as-text/121375/4 "2018-02-25T16:34:57Z")

</div>

Really?

Can you tell me what is the output of:

```
GET YOURINDEXNAME/_mapping

```

Also an exact document. I think your document has a `root` object in it which either should not be there or at least does not comply with the mapping.

And all formatted as explained in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21).

---

<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:** [March 25, 2018, 4:34pm UTC](https://discuss.elastic.co/t/map-date-as-text/121375/5 "2018-03-25T16:34:59Z")

</div>

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