# Unanalyzed string vs long on es 5.0

**URL:** <https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544>\
**Category:** Elasticsearch\
**Created:** [November 9, 2016, 6:51pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544 "2016-11-09T18:51:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [November 9, 2016, 6:51pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544/1 "2016-11-09T18:51:14Z")

</div>

All my rows in my table have a unique integer + unique slug (unchangable).

Is it a lot better to index a numeric field compared to string (based on changes on es 5)?

String is more readable when debugging, but if it's a big difference in size/ then I'll go for integers.

I will only index, not \_store / \_source.

Thank You!

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [November 11, 2016, 3:52pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544/2 "2016-11-11T15:52:19Z")

</div>

bump (after 2 days is enough I think)

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 11, 2016, 4:08pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544/3 "2016-11-11T16:08:01Z")

</div>

I'd use the slug as the \_id of the document so long as it is reasonably short. We already index \_uid (type + id) as a string so you may as well use it.

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [November 11, 2016, 4:23pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544/4 "2016-11-11T16:23:04Z")

</div>

@nik9000

Note that I'm asking what to store as a field in the mapping, not "\_id". But something like "field\_id" that I will later filter on (only on equality, no ranges).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 11, 2016, 4:50pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544/5 "2016-11-11T16:50:28Z")

</div>

> [@ddorian43](#):
>
> Note that I'm asking what to store as a field in the mapping

And I'm telling you that you can get away with adding neither to your mapping and using the slug as the id.

I don't know off hand whether it'd be better to add a string or a number to the mapping. It is worth testing, I think. So long as you won't be aggregating or sorting on the field I'd turn off doc\_values for it to save space.

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [November 11, 2016, 4:53pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544/6 "2016-11-11T16:53:07Z")

</div>

... I'm saying that will have other documents on es that will have a field called "field\_id" that I will use to filter on. That "thing\_id" can be either string/long.

I wasn't asking about storing the original "thing" document on es.

Thanks

---

<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:** [December 9, 2016, 4:53pm UTC](https://discuss.elastic.co/t/unanalyzed-string-vs-long-on-es-5-0/65544/7 "2016-12-09T16:53:11Z")

</div>

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