# Mapping for facets

**URL:** https://discuss.elastic.co/t/mapping-for-facets/12193
**Category:** Elasticsearch
**Created:** [May 30, 2013, 2:52pm UTC](https://discuss.elastic.co/t/mapping-for-facets/12193 "2013-05-30T14:52:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![TunaVargi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tunavargi/32/2306_2.png) [@TunaVargi](https://discuss.elastic.co/u/TunaVargi)
#### Post date: [May 30, 2013, 2:52pm UTC](https://discuss.elastic.co/t/mapping-for-facets/12193/1 "2013-05-30T14:52:54Z")

</div>

Hi ,

I want to have my facets as a single word , so I am using keyword analyzer  
as you see in destination\_facets and facet\_analyzer. But my facets comes as  
white space tokenized. Below you can find my mapping configuration . Any  
ideas?

{  
"mappings": {  
"hotel": {  
'properties': {"name": {  
"type": "string",  
"search\_analyzer": "str\_search\_analyzer",  
"index\_analyzer": "str\_index\_analyzer"},

```
            "destination": {'properties': {'en': {
                "type": "string",
                "search_analyzer": "str_search_analyzer",
                "index_analyzer": "str_index_analyzer"}}},

            "country": {"properties": {"en": {
                "type": "string",
                "search_analyzer": "str_search_analyzer",
                "index_analyzer": "str_index_analyzer"}}},
            "destination_facets": {"properties": {"en": {
                "type": "string",
                "search_analyzer": "facet_analyzer"
            }}}

            }
        }
    },
    "settings": {
        "analysis": {
            "analyzer": {
                "str_search_analyzer": {
                    "tokenizer": "keyword",
                    "filter": ["lowercase"]
                },

                "str_index_analyzer": {
                    "tokenizer": "keyword",
                    "filter": ["lowercase", "substring"]
                },
                "facet_analyzer": {
                    "type": "keyword",
                    "tokenizer": "keyword"
                },
            },

            "filter": {
                "substring": {
                    "type": "edgeNGram",
                    "min_gram": 1,
                    "max_gram": 20,
                }
            }
        }
    }
}

```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [May 30, 2013, 3:06pm UTC](https://discuss.elastic.co/t/mapping-for-facets/12193/2 "2013-05-30T15:06:41Z")

</div>

You set the search\_analyzer on the field, and not the index\_analyzer.  
Simply use the analyzer attribute instead.

If you are not using the keyword analyzer in conjunction with a filter  
(like your str\_search\_analyzer), I find it easier to simply mark the field  
as not\_analyzed.

--  
Ivan

On Thu, May 30, 2013 at 7:52 AM, TunaVargı [tuna40@gmail.com](mailto:tuna40@gmail.com) wrote:

> Hi ,
> 
> I want to have my facets as a single word , so I am using keyword analyzer  
> as you see in destination\_facets and facet\_analyzer. But my facets comes as  
> white space tokenized. Below you can find my mapping configuration . Any  
> ideas?
> 
> {  
> "mappings": {  
> "hotel": {  
> 'properties': {"name": {  
> "type": "string",  
> "search\_analyzer": "str\_search\_analyzer",  
> "index\_analyzer": "str\_index\_analyzer"},
> 
> ```
> "destination": {'properties': {'en': {
> "type": "string",
> "search_analyzer": "str_search_analyzer",
> "index_analyzer": "str_index_analyzer"}}},
> 
> "country": {"properties": {"en": {
> "type": "string",
> "search_analyzer": "str_search_analyzer",
> "index_analyzer": "str_index_analyzer"}}},
> "destination_facets": {"properties": {"en": {
> "type": "string",
> "search_analyzer": "facet_analyzer"
> }}}
> 
> }
> }
> },
> "settings": {
> "analysis": {
> "analyzer": {
> "str_search_analyzer": {
> "tokenizer": "keyword",
> "filter": ["lowercase"]
> },
> 
> "str_index_analyzer": {
> "tokenizer": "keyword",
> "filter": ["lowercase", "substring"]
> },
> "facet_analyzer": {
> "type": "keyword",
> "tokenizer": "keyword"
> },
> },
> 
> "filter": {
> "substring": {
> "type": "edgeNGram",
> "min_gram": 1,
> "max_gram": 20,
> }
> }
> }
> }
> }
> 
> ```
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![TunaVargi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tunavargi/32/2306_2.png) [@TunaVargi](https://discuss.elastic.co/u/TunaVargi)
#### Post date: [May 31, 2013, 6:21am UTC](https://discuss.elastic.co/t/mapping-for-facets/12193/3 "2013-05-31T06:21:07Z")

</div>

How can I set the field as not analyzed. I am using pyelasticsearch package  
for indexing. Is there a way to do that during mapping

30 Mayıs 2013 Perşembe 18:06:41 UTC+3 tarihinde Ivan Brusic yazdı:

> You set the search\_analyzer on the field, and not the index\_analyzer.  
> Simply use the analyzer attribute instead.
> 
> If you are not using the keyword analyzer in conjunction with a filter  
> (like your str\_search\_analyzer), I find it easier to simply mark the field  
> as not\_analyzed.
> 
> --  
> Ivan
> 
> On Thu, May 30, 2013 at 7:52 AM, TunaVargı \<[tun...@gmail.com](mailto:tun...@gmail.com) \<javascript:\>
> 
> > wrote:
> 
> > Hi ,
> > 
> > I want to have my facets as a single word , so I am using keyword  
> > analyzer as you see in destination\_facets and facet\_analyzer. But my facets  
> > comes as white space tokenized. Below you can find my mapping configuration  
> > . Any ideas?
> > 
> > {  
> > "mappings": {  
> > "hotel": {  
> > 'properties': {"name": {  
> > "type": "string",  
> > "search\_analyzer": "str\_search\_analyzer",  
> > "index\_analyzer": "str\_index\_analyzer"},
> > 
> > ```
> > "destination": {'properties': {'en': {
> > "type": "string",
> > "search_analyzer": "str_search_analyzer",
> > "index_analyzer": "str_index_analyzer"}}},
> > 
> > "country": {"properties": {"en": {
> > "type": "string",
> > "search_analyzer": "str_search_analyzer",
> > "index_analyzer": "str_index_analyzer"}}},
> > "destination_facets": {"properties": {"en": {
> > "type": "string",
> > "search_analyzer": "facet_analyzer"
> > }}}
> > 
> > }
> > }
> > },
> > "settings": {
> > "analysis": {
> > "analyzer": {
> > "str_search_analyzer": {
> > "tokenizer": "keyword",
> > "filter": ["lowercase"]
> > },
> > 
> > "str_index_analyzer": {
> > "tokenizer": "keyword",
> > "filter": ["lowercase", "substring"]
> > },
> > "facet_analyzer": {
> > "type": "keyword",
> > "tokenizer": "keyword"
> > },
> > },
> > 
> > "filter": {
> > "substring": {
> > "type": "edgeNGram",
> > "min_gram": 1,
> > "max_gram": 20,
> > }
> > }
> > }
> > }
> > }
> > 
> > ```
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [May 31, 2013, 6:27am UTC](https://discuss.elastic.co/t/mapping-for-facets/12193/4 "2013-05-31T06:27:07Z")

</div>

not\_analyzed is an index setting:  
"en" : {"type" : "string", "index" : "not\_analyzed"}

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

The effect is similar to having a keyword analyzer, but I prefer to think  
of such fields as not\_analyzed.

--  
Ivan

On Thu, May 30, 2013 at 11:21 PM, TunaVargı [tuna40@gmail.com](mailto:tuna40@gmail.com) wrote:

> How can I set the field as not analyzed. I am using pyelasticsearch  
> package for indexing. Is there a way to do that during mapping
> 
> 30 Mayıs 2013 Perşembe 18:06:41 UTC+3 tarihinde Ivan Brusic yazdı:
> 
> > You set the search\_analyzer on the field, and not the index\_analyzer.  
> > Simply use the analyzer attribute instead.
> > 
> > If you are not using the keyword analyzer in conjunction with a filter  
> > (like your str\_search\_analyzer), I find it easier to simply mark the field  
> > as not\_analyzed.
> > 
> > --  
> > Ivan
> > 
> > On Thu, May 30, 2013 at 7:52 AM, TunaVargı [tun...@gmail.com](mailto:tun...@gmail.com) wrote:
> > 
> > > Hi ,
> > > 
> > > I want to have my facets as a single word , so I am using keyword  
> > > analyzer as you see in destination\_facets and facet\_analyzer. But my facets  
> > > comes as white space tokenized. Below you can find my mapping configuration  
> > > . Any ideas?
> > > 
> > > {  
> > > "mappings": {  
> > > "hotel": {  
> > > 'properties': {"name": {  
> > > "type": "string",  
> > > "search\_analyzer": "str\_search\_analyzer",  
> > > "index\_analyzer": "str\_index\_analyzer"},
> > > 
> > > ```
> > > "destination": {'properties': {'en': {
> > > "type": "string",
> > > "search_analyzer": "str_search_analyzer",
> > > "index_analyzer": "str_index_analyzer"}}},
> > > 
> > > "country": {"properties": {"en": {
> > > "type": "string",
> > > "search_analyzer": "str_search_analyzer",
> > > "index_analyzer": "str_index_analyzer"}}},
> > > "destination_facets": {"properties": {"en": {
> > > "type": "string",
> > > "search_analyzer": "facet_analyzer"
> > > }}}
> > > 
> > > }
> > > }
> > > },
> > > "settings": {
> > > "analysis": {
> > > "analyzer": {
> > > "str_search_analyzer": {
> > > "tokenizer": "keyword",
> > > "filter": ["lowercase"]
> > > },
> > > 
> > > "str_index_analyzer": {
> > > "tokenizer": "keyword",
> > > "filter": ["lowercase", "substring"]
> > > },
> > > "facet_analyzer": {
> > > "type": "keyword",
> > > "tokenizer": "keyword"
> > > },
> > > },
> > > 
> > > "filter": {
> > > "substring": {
> > > "type": "edgeNGram",
> > > "min_gram": 1,
> > > "max_gram": 20,
> > > }
> > > }
> > > }
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![TunaVargi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tunavargi/32/2306_2.png) [@TunaVargi](https://discuss.elastic.co/u/TunaVargi)
#### Post date: [May 31, 2013, 6:38am UTC](https://discuss.elastic.co/t/mapping-for-facets/12193/5 "2013-05-31T06:38:54Z")

</div>

Thanks for the response, I tried it like this but my destination facets  
comes as whitespace tokenized. Altough I said not analyzed for it. Any  
ideas?  
{  
"mappings": {  
"hotel": {  
'properties': {"name": {  
"type": "string",  
"analyzer": "str\_index\_analyzer"},

```
            "destination": {'properties': {'en': {
                "type": "string",
                "analyzer": "str_index_analyzer"}}},

            "country": {"properties": {"en": {
                "type": "string",
                "analyzer": "str_index_analyzer"}}},
            "destination_facets": {"properties": {"en": {
                "type": "string",
                "index": "not_analyzed"
            }}}

            }
        }
    },
    "settings": {
        "analysis": {
            "analyzer": {
                "str_index_analyzer": {
                    "tokenizer": "keyword",
                    "filter": ["lowercase", "substring", "whitespace"]
                }
            },
            "filter": {
                "substring": {
                    "type": "edgeNGram",
                    "min_gram": 1,
                    "max_gram": 20,
                }
            }
        }
    }
}

```

30 Mayıs 2013 Perşembe 17:52:54 UTC+3 tarihinde TunaVargı yazdı:

> Hi ,
> 
> I want to have my facets as a single word , so I am using keyword analyzer  
> as you see in destination\_facets and facet\_analyzer. But my facets comes as  
> white space tokenized. Below you can find my mapping configuration . Any  
> ideas?
> 
> {  
> "mappings": {  
> "hotel": {  
> 'properties': {"name": {  
> "type": "string",  
> "search\_analyzer": "str\_search\_analyzer",  
> "index\_analyzer": "str\_index\_analyzer"},
> 
> ```
> "destination": {'properties': {'en': {
> "type": "string",
> "search_analyzer": "str_search_analyzer",
> "index_analyzer": "str_index_analyzer"}}},
> 
> "country": {"properties": {"en": {
> "type": "string",
> "search_analyzer": "str_search_analyzer",
> "index_analyzer": "str_index_analyzer"}}},
> "destination_facets": {"properties": {"en": {
> "type": "string",
> "search_analyzer": "facet_analyzer"
> }}}
> 
> }
> }
> },
> "settings": {
> "analysis": {
> "analyzer": {
> "str_search_analyzer": {
> "tokenizer": "keyword",
> "filter": ["lowercase"]
> },
> 
> "str_index_analyzer": {
> "tokenizer": "keyword",
> "filter": ["lowercase", "substring"]
> },
> "facet_analyzer": {
> "type": "keyword",
> "tokenizer": "keyword"
> },
> },
> 
> "filter": {
> "substring": {
> "type": "edgeNGram",
> "min_gram": 1,
> "max_gram": 20,
> }
> }
> }
> }
> }
> 
> ```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [July 6, 2017, 2:33am UTC](https://discuss.elastic.co/t/mapping-for-facets/12193/6 "2017-07-06T02:33:43Z")

</div>


