# Create keyword string type with custom analyzer in 5.3.0

**URL:** https://discuss.elastic.co/t/create-keyword-string-type-with-custom-analyzer-in-5-3-0/82440
**Category:** Elasticsearch
**Created:** [April 14, 2017, 6:52pm UTC](https://discuss.elastic.co/t/create-keyword-string-type-with-custom-analyzer-in-5-3-0/82440 "2017-04-14T18:52:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![oleksiy](https://avatars.discourse-cdn.com/v4/letter/o/2bfe46/32.png) [@oleksiy](https://discuss.elastic.co/u/oleksiy)
#### Post date: [April 14, 2017, 6:52pm UTC](https://discuss.elastic.co/t/create-keyword-string-type-with-custom-analyzer-in-5-3-0/82440/1 "2017-04-14T18:52:31Z")

</div>

I have a string I'd like to index as keyword type but with a special comma analyzer:  
For example:

`"San Francisco, Boston, New York"`

should be both indexed and aggregatable at the same time so that I can split it up by buckets. In pre 5.0.0 the following worked:  
Index settings:

```
 {
         'settings': {
             'analysis': {
                 'tokenizer': {
                     'comma': {
                         'type': 'pattern',
                         'pattern': ','
                     }
                 },
                 'analyzer': {
                     'comma': {
                         'type': 'custom',
                         'tokenizer': 'comma'
                     }
                 }
             },
         },
 }

```

with the following mapping:

```
{
        'city': {
            'type': 'string',
            'analyzer': 'comma'
        },
}

```

Now in 5.3.0 and above the `analyzer` is no longer a valid property for the `keyword` type, and my undestanding is that I want a `keyword` here. How do I specify an aggregatable, indexed, searchable text type with custom analyser?

---

<div class="post-metadata">

### Author: ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)
#### Post date: [April 21, 2017, 7:48am UTC](https://discuss.elastic.co/t/create-keyword-string-type-with-custom-analyzer-in-5-3-0/82440/2 "2017-04-21T07:48:39Z")

</div>

if you specify an analyzer that produces more than one token you have to use `text` type since it's not a keyword. if you wanna use a `normalizer` you can use a [keyword](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/keyword.html) type but then you need to split your tokens in the client and send a list (`"San Francisco, Boston, New York" -> ["San Francisco", "Boston", "New York"]`) Since keywords don't allow tokenization. If you use `text` as a type you can't use docvalues anymore and for aggregations all terms will be loaded into memory.

---

<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 19, 2017, 7:50am UTC](https://discuss.elastic.co/t/create-keyword-string-type-with-custom-analyzer-in-5-3-0/82440/3 "2017-05-19T07:50:59Z")

</div>

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