# Why i should pre-define the fields?

**URL:** <https://discuss.elastic.co/t/why-i-should-pre-define-the-fields/297076>\
**Category:** Logstash\
**Created:** [February 13, 2022, 12:18pm UTC](https://discuss.elastic.co/t/why-i-should-pre-define-the-fields/297076 "2022-02-13T12:18:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nasser](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nasser/32/99437_2.png) [@Nasser](https://discuss.elastic.co/u/Nasser)\
**Post date:** [February 13, 2022, 12:18pm UTC](https://discuss.elastic.co/t/why-i-should-pre-define-the-fields/297076/1 "2022-02-13T12:18:38Z")

</div>

Hi  
what is the benefit to pre-define the fields while the elastic will identify the fields automatically ?  
please need some explanation 🙂

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [February 13, 2022, 12:49pm UTC](https://discuss.elastic.co/t/why-i-should-pre-define-the-fields/297076/2 "2022-02-13T12:49:08Z")

</div>

Is this question is about Logstash? or Elasticsearch itself.

For Elasticsearch, Dynamic field mapping is not perfect, and it is difficult in nature.  
As Elasticsearch decide the mapping by the first value of the field, it can't distinguish text and keyword (Elasticsearch map string fields as text fields with keyword multi-fields). The first value: 1 could not tell all following value is only integer or containing some float, and the extent is also unkown.

Explicit field mapping is the way to tell Elasticsearch what type of data is comming in future.

---

<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 13, 2022, 12:49pm UTC](https://discuss.elastic.co/t/why-i-should-pre-define-the-fields/297076/3 "2022-03-13T12:49:42Z")

</div>

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