# Keyword field that is automatically appended to text field?

**URL:** https://discuss.elastic.co/t/keyword-field-that-is-automatically-appended-to-text-field/130313
**Category:** Elasticsearch
**Created:** [May 2, 2018, 7:22pm UTC](https://discuss.elastic.co/t/keyword-field-that-is-automatically-appended-to-text-field/130313 "2018-05-02T19:22:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![David9](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david9/32/42150_2.png) [@David9](https://discuss.elastic.co/u/David9)
#### Post date: [May 2, 2018, 7:22pm UTC](https://discuss.elastic.co/t/keyword-field-that-is-automatically-appended-to-text-field/130313/1 "2018-05-02T19:22:28Z")

</div>

We're relatively new to ES and discovered that after indexing some data, fields that are of type text now have a sub-field 'keyword' of type 'keyword'. Is this there to allow aggregation or other searches that are not allowed on text fields?

If so, and if we are starting our project from scratch, is it advisable to go this route so we can either do full text queries on the field, or keyword queries on the .keyword field...or should we make our field of type keyword to begin with? We are honestly not sure whether we will do stem-like queries on the field, so we'd like to be able to do either type of query. Thanks

---

<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: [May 2, 2018, 7:41pm UTC](https://discuss.elastic.co/t/keyword-field-that-is-automatically-appended-to-text-field/130313/2 "2018-05-02T19:41:03Z")

</div>

> Is this there to allow aggregation or other searches that are not allowed on text fields?

Yes. Aggs and Sorting most of the time.

Basically if you want to run full text search on a field where scoring is important for example, or using fuzzy queries, then use a `text` field.  
If you need to compute aggs or do sorting, use `keyword`.

If you need to do both, do like elasticsearch is doing by default:

- The field is a `text` type
- The subfield `*.keyword` is a `keyword` type

---

<div class="post-metadata">

### Author: ![David9](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david9/32/42150_2.png) [@David9](https://discuss.elastic.co/u/David9)
#### Post date: [May 2, 2018, 10:05pm UTC](https://discuss.elastic.co/t/keyword-field-that-is-automatically-appended-to-text-field/130313/3 "2018-05-02T22:05:34Z")

</div>

thanks! where is this documented? I can't find an explanation of that for 6.2

---

<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: [May 3, 2018, 5:26am UTC](https://discuss.elastic.co/t/keyword-field-that-is-automatically-appended-to-text-field/130313/4 "2018-05-03T05:26:56Z")

</div>

There: [https://www.elastic.co/guide/en/elasticsearch/reference/6.2/keyword.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/keyword.html)

---

<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: [May 31, 2018, 5:27am UTC](https://discuss.elastic.co/t/keyword-field-that-is-automatically-appended-to-text-field/130313/5 "2018-05-31T05:27:01Z")

</div>

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