# Data ignores datatype!

**URL:** <https://discuss.elastic.co/t/data-ignores-datatype/159849>\
**Category:** Elasticsearch\
**Created:** [December 7, 2018, 5:54am UTC](https://discuss.elastic.co/t/data-ignores-datatype/159849 "2018-12-07T05:54:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![inandi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inandi/32/40801_2.png) [@inandi](https://discuss.elastic.co/u/inandi)\
**Post date:** [December 7, 2018, 5:54am UTC](https://discuss.elastic.co/t/data-ignores-datatype/159849/1 "2018-12-07T05:54:44Z")

</div>

I am trying to insert data to ES using logstash template. Data is inserting fine but I have an issue with the data type. I have set datatype date for a particular data (in example **reviewId** ), but it is also letting insert string datatype. I want to restrict this kind of insertion.

here is my **template**

```
{
  "index_patterns": ["my_index_*"],
  "settings": {
    "index": {
      "number_of_shards": "2",
      "number_of_replicas": "1"
    }
  },
  "mappings": {
    "doc":{
      "dynamic": "false",
      "properties": {
        "reviewId": {
          "type": "date"
        }
      }
    }
  },
  "aliases": {}
}

```

my **data**

> `{"reviewId":"hello i am string","reviewer":{"profilePhotoUrl":bla bla","displayName":"Afrid Khan"},"starRating":"FIVE","comment":"Good working environment","createTime":"2018-11-21T11:38:54.366207Z","updateTime":"2018-11-21T11:39:11.527644Z","name":"bla bla"}`

field **reviewId** is set to be a date type, but it is still inserting into ES.

Not only for a date, but I also want to restrict insertion if data does not match with correspondent type. How to prevent that ?

Thanks n Regards  
@inandi

---

<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:** [December 7, 2018, 6:29am UTC](https://discuss.elastic.co/t/data-ignores-datatype/159849/2 "2018-12-07T06:29:23Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![inandi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/inandi/32/40801_2.png) [@inandi](https://discuss.elastic.co/u/inandi)\
**Post date:** [December 7, 2018, 6:33am UTC](https://discuss.elastic.co/t/data-ignores-datatype/159849/3 "2018-12-07T06:33:43Z")

</div>

ooops!!! my mistake @dadoonet , thanks for your suggestion. I will update my post.

---

<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:** [January 4, 2019, 6:33am UTC](https://discuss.elastic.co/t/data-ignores-datatype/159849/4 "2019-01-04T06:33:47Z")

</div>

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