# Search analyzer not being applied

**URL:** <https://discuss.elastic.co/t/search-analyzer-not-being-applied/5288>\
**Category:** Elasticsearch\
**Created:** [August 31, 2011, 1:43pm UTC](https://discuss.elastic.co/t/search-analyzer-not-being-applied/5288 "2011-08-31T13:43:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mattias\_Nordberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattias_nordberg/32/3131_2.png) [@Mattias\_Nordberg](https://discuss.elastic.co/u/Mattias_Nordberg)\
**Post date:** [August 31, 2011, 1:43pm UTC](https://discuss.elastic.co/t/search-analyzer-not-being-applied/5288/1 "2011-08-31T13:43:26Z")

</div>

Hi,

I've got an index which has been configured to use the snowball  
analyzer (English) as both index\_analyzer and search\_analyzer. The  
problem is that it doesn't appear to be applied to any search queries,  
but works perfectly at indexing time.

My analyzer in elasticsearch.json:  
"index":{  
"analysis":{  
"analyzer":{  
"snowball\_en":{  
"type":"snowball",  
"language":"English"  
}  
}  
}  
}

Looking at \_cluster/state, I've successfully configured a template  
that will assign that analyzer to any new index ending in "\_en".  
"templates" : {  
"english\_index" : {  
"template" : "\*\_en",  
"order" : 0,  
"settings" : {  
},  
"mappings" : {  
"webpage" : {  
"index\_analyzer" : "snowball\_en",  
"search\_analyzer" : "snowball\_en"  
}  
}  
}

Again in \_cluster/state, the english index:  
"indices" : {  
"test\_en" : {  
"state" : "open",  
"settings" : {  
"index.number\_of\_shards" : "5",  
"index.number\_of\_replicas" : "1"  
},  
"mappings" : {  
"webpage" : {  
"\_source" : {  
"compress" : true  
},  
"dynamic\_templates" : [ {  
"everything\_else" : {  
"mapping" : {  
"include\_in\_all" : false,  
"index" : "not\_analyzed",  
"type" : "string"  
},  
"match\_mapping\_type" : "string",  
"match" : "\*"  
}  
} ],  
"analyzer" : "snowball\_en",  
"properties" : {  
"id" : {  
"include\_in\_all" : false,  
"index" : "not\_analyzed",  
"type" : "string"  
},  
"title" : {  
"include\_in\_all" : true,  
"type" : "string"  
},  
"text" : {  
"include\_in\_all" : true,  
"type" : "string"  
},  
"language" : {  
"include\_in\_all" : false,  
"index" : "not\_analyzed",  
"type" : "string"  
},  
"url" : {  
"include\_in\_all" : true,  
"index" : "not\_analyzed",  
"type" : "string"  
},  
"fields" : {  
"dynamic" : "true",  
"properties" : {  
"tags" : {  
"include\_in\_all" : false,  
"index" : "not\_analyzed",  
"type" : "string"  
}  
}  
}  
}  
}  
},  
"aliases" : []  
}  
}  
}

What I get when I run a test analysis against that index:  
curl -XGET 'localhost:9200/test\_en/\_analyze' -d 'getting started'  
{"tokens":[{"token":"getting","start\_offset":0,"end\_offset":  
7,"type":"","position":1},{"token":"started","start\_offset":  
8,"end\_offset":15,"type":"","position":2}]}

If I explicitly specify the analyzer:  
curl -XGET 'localhost:9200/test\_en/\_analyze?analyzer=snowball\_en' -d  
'getting started'  
{"tokens":[{"token":"get","start\_offset":0,"end\_offset":  
7,"type":"","position":1},{"token":"start","start\_offset":  
8,"end\_offset":15,"type":"","position":2}]}

My understanding was that specifying 'search\_analyzer' would cause  
elasticsearch to analyze the query string and in this case the two  
statements above would return the same result?

Best regards  
Mattias

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 31, 2011, 2:07pm UTC](https://discuss.elastic.co/t/search-analyzer-not-being-applied/5288/2 "2011-08-31T14:07:13Z")

</div>

You set it on the mapping level for webpage, which has no concept of  
index\_analyzer or search\_analyzer. Do you want to set it as the default  
analyzer for the index? If so, in your analysis config, simply configure a  
"default" analyzer (name) that has the snowball properties.

On Wed, Aug 31, 2011 at 4:43 PM, Mattias Nordberg \<  
[mattias.nordberg@gmail.com](mailto:mattias.nordberg@gmail.com)\> wrote:

> Hi,
> 
> I've got an index which has been configured to use the snowball  
> analyzer (English) as both index\_analyzer and search\_analyzer. The  
> problem is that it doesn't appear to be applied to any search queries,  
> but works perfectly at indexing time.
> 
> My analyzer in elasticsearch.json:  
> "index":{  
> "analysis":{  
> "analyzer":{  
> "snowball\_en":{  
> "type":"snowball",  
> "language":"English"  
> }  
> }  
> }  
> }
> 
> Looking at \_cluster/state, I've successfully configured a template  
> that will assign that analyzer to any new index ending in "\_en".  
> "templates" : {  
> "english\_index" : {  
> "template" : "\*\_en",  
> "order" : 0,  
> "settings" : {  
> },  
> "mappings" : {  
> "webpage" : {  
> "index\_analyzer" : "snowball\_en",  
> "search\_analyzer" : "snowball\_en"  
> }  
> }  
> }
> 
> Again in \_cluster/state, the english index:  
> "indices" : {  
> "test\_en" : {  
> "state" : "open",  
> "settings" : {  
> "index.number\_of\_shards" : "5",  
> "index.number\_of\_replicas" : "1"  
> },  
> "mappings" : {  
> "webpage" : {  
> "\_source" : {  
> "compress" : true  
> },  
> "dynamic\_templates" : [ {  
> "everything\_else" : {  
> "mapping" : {  
> "include\_in\_all" : false,  
> "index" : "not\_analyzed",  
> "type" : "string"  
> },  
> "match\_mapping\_type" : "string",  
> "match" : "\*"  
> }  
> } ],  
> "analyzer" : "snowball\_en",  
> "properties" : {  
> "id" : {  
> "include\_in\_all" : false,  
> "index" : "not\_analyzed",  
> "type" : "string"  
> },  
> "title" : {  
> "include\_in\_all" : true,  
> "type" : "string"  
> },  
> "text" : {  
> "include\_in\_all" : true,  
> "type" : "string"  
> },  
> "language" : {  
> "include\_in\_all" : false,  
> "index" : "not\_analyzed",  
> "type" : "string"  
> },  
> "url" : {  
> "include\_in\_all" : true,  
> "index" : "not\_analyzed",  
> "type" : "string"  
> },  
> "fields" : {  
> "dynamic" : "true",  
> "properties" : {  
> "tags" : {  
> "include\_in\_all" : false,  
> "index" : "not\_analyzed",  
> "type" : "string"  
> }  
> }  
> }  
> }  
> }  
> },  
> "aliases" :   
> }  
> }  
> }
> 
> What I get when I run a test analysis against that index:  
> curl -XGET 'localhost:9200/test\_en/\_analyze' -d 'getting started'  
> {"tokens":[{"token":"getting","start\_offset":0,"end\_offset":  
> 7,"type":"","position":1},{"token":"started","start\_offset":  
> 8,"end\_offset":15,"type":"","position":2}]}
> 
> If I explicitly specify the analyzer:  
> curl -XGET 'localhost:9200/test\_en/\_analyze?analyzer=snowball\_en' -d  
> 'getting started'  
> {"tokens":[{"token":"get","start\_offset":0,"end\_offset":  
> 7,"type":"","position":1},{"token":"start","start\_offset":  
> 8,"end\_offset":15,"type":"","position":2}]}
> 
> My understanding was that specifying 'search\_analyzer' would cause  
> elasticsearch to analyze the query string and in this case the two  
> statements above would return the same result?
> 
> Best regards  
> Mattias

---

<div class="post-metadata">

**Author:** ![Mattias\_Nordberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattias_nordberg/32/3131_2.png) [@Mattias\_Nordberg](https://discuss.elastic.co/u/Mattias_Nordberg)\
**Post date:** [August 31, 2011, 2:23pm UTC](https://discuss.elastic.co/t/search-analyzer-not-being-applied/5288/3 "2011-08-31T14:23:08Z")

</div>

Well, yeah but I want it to be dependent on the language of the index  
which I indicate with the language code suffix on the index name. I've  
got two templates, one for english indices and one for swedish  
indices, \_en should get snowball\_en and \_sv should get snowball\_sv.  
Can I set the analyzer in the template? I tried, but as you say it  
ended up on the mapping 🙂

Many thanks  
Mattias

On Aug 31, 3:07 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You set it on the mapping level for webpage, which has no concept of  
> index\_analyzer or search\_analyzer. Do you want to set it as the default  
> analyzer for the index? If so, in your analysis config, simply configure a  
> "default" analyzer (name) that has the snowball properties.
> 
> On Wed, Aug 31, 2011 at 4:43 PM, Mattias Nordberg \<
> 
> [mattias.nordb...@gmail.com](mailto:mattias.nordb...@gmail.com)\> wrote:
> 
> > Hi,
> 
> > I've got an index which has been configured to use the snowball  
> > analyzer (English) as both index\_analyzer and search\_analyzer. The  
> > problem is that it doesn't appear to be applied to any search queries,  
> > but works perfectly at indexing time.
> 
> > My analyzer in elasticsearch.json:  
> > "index":{  
> > "analysis":{  
> > "analyzer":{  
> > "snowball\_en":{  
> > "type":"snowball",  
> > "language":"English"  
> > }  
> > }  
> > }  
> > }
> 
> > Looking at \_cluster/state, I've successfully configured a template  
> > that will assign that analyzer to any new index ending in "\_en".  
> > "templates" : {  
> > "english\_index" : {  
> > "template" : "\*\_en",  
> > "order" : 0,  
> > "settings" : {  
> > },  
> > "mappings" : {  
> > "webpage" : {  
> > "index\_analyzer" : "snowball\_en",  
> > "search\_analyzer" : "snowball\_en"  
> > }  
> > }  
> > }
> 
> > Again in \_cluster/state, the english index:  
> > "indices" : {  
> > "test\_en" : {  
> > "state" : "open",  
> > "settings" : {  
> > "index.number\_of\_shards" : "5",  
> > "index.number\_of\_replicas" : "1"  
> > },  
> > "mappings" : {  
> > "webpage" : {  
> > "\_source" : {  
> > "compress" : true  
> > },  
> > "dynamic\_templates" : [ {  
> > "everything\_else" : {  
> > "mapping" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "match\_mapping\_type" : "string",  
> > "match" : "\*"  
> > }  
> > } ],  
> > "analyzer" : "snowball\_en",  
> > "properties" : {  
> > "id" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "title" : {  
> > "include\_in\_all" : true,  
> > "type" : "string"  
> > },  
> > "text" : {  
> > "include\_in\_all" : true,  
> > "type" : "string"  
> > },  
> > "language" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "url" : {  
> > "include\_in\_all" : true,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "fields" : {  
> > "dynamic" : "true",  
> > "properties" : {  
> > "tags" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "aliases" :   
> > }  
> > }  
> > }
> 
> > What I get when I run a test analysis against that index:  
> > curl -XGET 'localhost:9200/test\_en/\_analyze' -d 'getting started'  
> > {"tokens":[{"token":"getting","start\_offset":0,"end\_offset":  
> > 7,"type":"","position":1},{"token":"started","start\_offset":  
> > 8,"end\_offset":15,"type":"","position":2}]}
> 
> > If I explicitly specify the analyzer:  
> > curl -XGET 'localhost:9200/test\_en/\_analyze?analyzer=snowball\_en' -d  
> > 'getting started'  
> > {"tokens":[{"token":"get","start\_offset":0,"end\_offset":  
> > 7,"type":"","position":1},{"token":"start","start\_offset":  
> > 8,"end\_offset":15,"type":"","position":2}]}
> 
> > My understanding was that specifying 'search\_analyzer' would cause  
> > elasticsearch to analyze the query string and in this case the two  
> > statements above would return the same result?
> 
> > Best regards  
> > Mattias

---

<div class="post-metadata">

**Author:** ![Mattias\_Nordberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattias_nordberg/32/3131_2.png) [@Mattias\_Nordberg](https://discuss.elastic.co/u/Mattias_Nordberg)\
**Post date:** [August 31, 2011, 3:07pm UTC](https://discuss.elastic.co/t/search-analyzer-not-being-applied/5288/4 "2011-08-31T15:07:26Z")

</div>

I got it working by passing in the module settings in the template, as  
the documentation mentioned 🙂 Thanks for you help.

On Aug 31, 3:07 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You set it on the mapping level for webpage, which has no concept of  
> index\_analyzer or search\_analyzer. Do you want to set it as the default  
> analyzer for the index? If so, in your analysis config, simply configure a  
> "default" analyzer (name) that has the snowball properties.
> 
> On Wed, Aug 31, 2011 at 4:43 PM, Mattias Nordberg \<
> 
> [mattias.nordb...@gmail.com](mailto:mattias.nordb...@gmail.com)\> wrote:
> 
> > Hi,
> 
> > I've got an index which has been configured to use the snowball  
> > analyzer (English) as both index\_analyzer and search\_analyzer. The  
> > problem is that it doesn't appear to be applied to any search queries,  
> > but works perfectly at indexing time.
> 
> > My analyzer in elasticsearch.json:  
> > "index":{  
> > "analysis":{  
> > "analyzer":{  
> > "snowball\_en":{  
> > "type":"snowball",  
> > "language":"English"  
> > }  
> > }  
> > }  
> > }
> 
> > Looking at \_cluster/state, I've successfully configured a template  
> > that will assign that analyzer to any new index ending in "\_en".  
> > "templates" : {  
> > "english\_index" : {  
> > "template" : "\*\_en",  
> > "order" : 0,  
> > "settings" : {  
> > },  
> > "mappings" : {  
> > "webpage" : {  
> > "index\_analyzer" : "snowball\_en",  
> > "search\_analyzer" : "snowball\_en"  
> > }  
> > }  
> > }
> 
> > Again in \_cluster/state, the english index:  
> > "indices" : {  
> > "test\_en" : {  
> > "state" : "open",  
> > "settings" : {  
> > "index.number\_of\_shards" : "5",  
> > "index.number\_of\_replicas" : "1"  
> > },  
> > "mappings" : {  
> > "webpage" : {  
> > "\_source" : {  
> > "compress" : true  
> > },  
> > "dynamic\_templates" : [ {  
> > "everything\_else" : {  
> > "mapping" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "match\_mapping\_type" : "string",  
> > "match" : "\*"  
> > }  
> > } ],  
> > "analyzer" : "snowball\_en",  
> > "properties" : {  
> > "id" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "title" : {  
> > "include\_in\_all" : true,  
> > "type" : "string"  
> > },  
> > "text" : {  
> > "include\_in\_all" : true,  
> > "type" : "string"  
> > },  
> > "language" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "url" : {  
> > "include\_in\_all" : true,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > },  
> > "fields" : {  
> > "dynamic" : "true",  
> > "properties" : {  
> > "tags" : {  
> > "include\_in\_all" : false,  
> > "index" : "not\_analyzed",  
> > "type" : "string"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > },  
> > "aliases" :   
> > }  
> > }  
> > }
> 
> > What I get when I run a test analysis against that index:  
> > curl -XGET 'localhost:9200/test\_en/\_analyze' -d 'getting started'  
> > {"tokens":[{"token":"getting","start\_offset":0,"end\_offset":  
> > 7,"type":"","position":1},{"token":"started","start\_offset":  
> > 8,"end\_offset":15,"type":"","position":2}]}
> 
> > If I explicitly specify the analyzer:  
> > curl -XGET 'localhost:9200/test\_en/\_analyze?analyzer=snowball\_en' -d  
> > 'getting started'  
> > {"tokens":[{"token":"get","start\_offset":0,"end\_offset":  
> > 7,"type":"","position":1},{"token":"start","start\_offset":  
> > 8,"end\_offset":15,"type":"","position":2}]}
> 
> > My understanding was that specifying 'search\_analyzer' would cause  
> > elasticsearch to analyze the query string and in this case the two  
> > statements above would return the same result?
> 
> > Best regards  
> > Mattias

---

<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, 3:55am UTC](https://discuss.elastic.co/t/search-analyzer-not-being-applied/5288/5 "2017-07-06T03:55:27Z")

</div>


