# Elastic String Types

**URL:** <https://discuss.elastic.co/t/elastic-string-types/137413>\
**Category:** Elasticsearch\
**Created:** [June 26, 2018, 10:06am UTC](https://discuss.elastic.co/t/elastic-string-types/137413 "2018-06-26T10:06:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![safhw91](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@safhw91](https://discuss.elastic.co/u/safhw91)\
**Post date:** [June 26, 2018, 10:06am UTC](https://discuss.elastic.co/t/elastic-string-types/137413/1 "2018-06-26T10:06:18Z")

</div>

Now a "String" can be either (or both) a "Text" or "Keyword" type.

If it's "text", then Elastic can do a full text search on it.  
If it's "keyword", then Elastic can do structured search on it.

Which one takes less of a toll in memory? I would assume keyword but I have no clue whether Elastic is putting even more stuff in memory for the "Text" type.

Also, is there any data type which simply stores the data and can be retrieved when searching by e.g. ID? Both "text" and "keyword" type seems like it needs to put the data in memory, but there are some pieces of data that I don't care about and just need to store and retrieve together when I search via other means.

---

<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:** [June 26, 2018, 2:00pm UTC](https://discuss.elastic.co/t/elastic-string-types/137413/2 "2018-06-26T14:00:35Z")

</div>

If you want to search for exact match, I'd probably use a `text` type with a `keyword` analyzer.  
If you want to do sorting, aggregations in addition, I'd use a `keyword` datatype instead.

My 2 cents

---

<div class="post-metadata">

**Author:** ![safhw91](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@safhw91](https://discuss.elastic.co/u/safhw91)\
**Post date:** [June 27, 2018, 2:42am UTC](https://discuss.elastic.co/t/elastic-string-types/137413/3 "2018-06-27T02:42:40Z")

</div>

\*Edit: solved.

Keyword is more memory efficient.

---

<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:** [June 27, 2018, 3:59am UTC](https://discuss.elastic.co/t/elastic-string-types/137413/4 "2018-06-27T03:59:53Z")

</div>

Please see [Text VS Keyword](https://discuss.elastic.co/t/text-vs-keyword/137532/4?u=dadoonet)

It'd have been better to keep the discussion in the same thread as it's totally related IMO.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 27, 2018, 4:14am UTC](https://discuss.elastic.co/t/elastic-string-types/137413/5 "2018-06-27T04:14:24Z")

</div>


