# What all are the possible problems if I don't give keyword mapping to my text type?

**URL:** https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723
**Category:** Elasticsearch
**Created:** [November 30, 2017, 9:58am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723 "2017-11-30T09:58:26Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [November 30, 2017, 9:58am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723/1 "2017-11-30T09:58:26Z")

</div>

Hi,

I have a mapping like below;

```
PUT _template/my_template
{
  "index_patterns": ["mylogs*"],
  "mappings": {
    "doc": {
      "properties": {
        .
		.
		.
        "long_text_field_1": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
			  "ignore_above": 10922
            }
          }
        },
		"long_text_field_2": {
          "type": "text"
        },
        .
		.
		.
      }
    }
  }
}

```

The fields are long UTF-8 text fields. What all will be the performance / other difference between these two fields, assuming that the size of contents in these 2 fields are same. What all operations are possible / not possible?

Thanks.

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [November 30, 2017, 10:23am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723/2 "2017-11-30T10:23:18Z")

</div>

Why would you need a single token be up to 10922 characters in length?

- Users are unlikely to perform exact-match searches by typing in a 10k length string
- Users are unlikely to select a 10k length string from a drop-down box in a structured form
- Users are unlikely to want to perform aggregations where a bar on a bar chart is labelled with a 10k length string.

The only scenario I can conceive of is where something like a long URL is stored in a system and you want to perform some analysis on URL usage. You're likely still going to end up with a cripplingly large number of unique strings in your index. Hashes may be a better approach in these circumstances

---

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [November 30, 2017, 10:28am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723/3 "2017-11-30T10:28:35Z")

</div>

Thanks @Mark_Harwood

My intention was just to search inside those long text fields. Not the entire text, but keywords inside that. In this case, kindly tell me is it OK to go with the below config;

```
    "long_text_field_1": {
      "type": "text",
      "fields": {
        "keyword": {
          "type": "keyword",
		  "ignore_above": 256
        }
      }
    },
	"long_text_field_2": {
      "type": "text",
      "fields": {
        "keyword": {
          "type": "keyword",
		  "ignore_above": 256
        }
      }
    },
```

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [November 30, 2017, 10:33am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723/4 "2017-11-30T10:33:18Z")

</div>

> [@elasticcloud](#):
>
> My intention was just to search inside those long text fields. Not the entire text, but keywords inside that.

That's perhaps the misinterpretation then. It's "keyword" singular, not plural. A keyword string is treated as a single untokenized keyword like `science fiction` as opposed to a `text` string which is tokenized into the words `science` and `fiction`.

---

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [November 30, 2017, 10:53am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723/5 "2017-11-30T10:53:45Z")

</div>

Ok. So it denotes the size of "each keyword" inside my entire text. So I can very well go with 256 😀

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [November 30, 2017, 10:57am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723/6 "2017-11-30T10:57:39Z")

</div>

> [@elasticcloud](#):
>
> Ok. So it denotes the size of "each keyword" inside my entire text. So I can very well go with 256

Nope. It dictates the maximum length of a string that will be stored as an untokenized keyword.  
"Keyword" does not mean substring. The process of creating substrings for search is `tokenization` to chop string fields of the type "text" into individual `tokens`.  
Strings of the type `keyword` are not tokenized.

---

<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 28, 2017, 10:57am UTC](https://discuss.elastic.co/t/what-all-are-the-possible-problems-if-i-dont-give-keyword-mapping-to-my-text-type/109723/7 "2017-12-28T10:57:47Z")

</div>

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