# How does Elasticsearch indexes non-text fields

**URL:** <https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072>\
**Category:** Elasticsearch\
**Created:** [August 27, 2022, 10:46pm UTC](https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072 "2022-08-27T22:46:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImranArif](https://avatars.discourse-cdn.com/v4/letter/i/a5b964/32.png) [@ImranArif](https://discuss.elastic.co/u/ImranArif)\
**Post date:** [August 27, 2022, 10:46pm UTC](https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072/1 "2022-08-27T22:46:12Z")

</div>

Hi,

I understand that Elasticsearch analyzes text fields and saves the resulting tokens in an inverted index data structure. But I am a bit confused regarding how does Elasticsearch stores other fields, like integer, float, and keyword? Does it treat values of these fields as tokens (without breaking further into tokens) and stores those values in an inverted index as it is? Or does it store those values in a separate data structure?

Thanks.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [August 28, 2022, 1:24am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072/2 "2022-08-28T01:24:02Z")

</div>

Perhaps take a read through this.

`keyword`, numerics `date` etc are not tokenized.. only `text` fields are tokenized

`keyword`s are stored in the inverted index and doc\_values as well

> **[doc\_values | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html)**

Numerics are also stored in the inverted index but with some other meta data to support range searches etc.

> [@How are numeric data types indexed?](https://discuss.elastic.co/t/how-are-numeric-data-types-indexed/187418/2):
>
> There are lots of different mapping types you can use for numeric values, depending on the precision you need. Take a look at [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html). The numeric types are optimised for the type of searches you would typically run against a numeric type, like ranges. This means that there is some extra data stored along with the value. If you're not going to be running range queries on the numeric fields and are just storing them for lookup, aggregation or ordering purposes, using a keyword mapping…

---

<div class="post-metadata">

**Author:** ![ImranArif](https://avatars.discourse-cdn.com/v4/letter/i/a5b964/32.png) [@ImranArif](https://discuss.elastic.co/u/ImranArif)\
**Post date:** [August 28, 2022, 3:40am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072/3 "2022-08-28T03:40:32Z")

</div>

Thanks @stephenb

So this means that numeric and keyword types both have doc\_values enabled by default, in order to optimize and support aggregation, sorting and lookup on those fields. But with numeric types there is an additional metadata stored, which is specifically to make range queries more efficient.

Please let me know if my understanding is correct.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [August 28, 2022, 4:07am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072/4 "2022-08-28T04:07:00Z")

</div>

Yes, that's generally correct, of course there's a lot of low level detail.

If there's something specific you're trying to solve, perhaps you should open a thread with the specific issue you are trying to solve.

---

<div class="post-metadata">

**Author:** ![ImranArif](https://avatars.discourse-cdn.com/v4/letter/i/a5b964/32.png) [@ImranArif](https://discuss.elastic.co/u/ImranArif)\
**Post date:** [August 28, 2022, 7:32am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072/5 "2022-08-28T07:32:21Z")

</div>

Thanks much @stephenb  
I am not solving any problem at the moment. I am trying to understand ELK stack.

---

<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:** [September 25, 2022, 7:33am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-indexes-non-text-fields/313072/6 "2022-09-25T07:33:03Z")

</div>

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