# Disable custom analyzer for prefix filter

**URL:** <https://discuss.elastic.co/t/disable-custom-analyzer-for-prefix-filter/8466>\
**Category:** Elasticsearch\
**Created:** [July 19, 2012, 3:01pm UTC](https://discuss.elastic.co/t/disable-custom-analyzer-for-prefix-filter/8466 "2012-07-19T15:01:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![George\_Sakkis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/george_sakkis/32/2801_2.png) [@George\_Sakkis](https://discuss.elastic.co/u/George_Sakkis)\
**Post date:** [July 19, 2012, 3:01pm UTC](https://discuss.elastic.co/t/disable-custom-analyzer-for-prefix-filter/8466/1 "2012-07-19T15:01:34Z")

</div>

Hi all,

I have defined a custom default analyzer that works fine for "text"  
and "string\_query" type queries but is problematic for prefix filters.  
Here is a simpler example using the "english" analyzer:

curl -XPUT '[http://localhost:9200/twitter](http://localhost:9200/twitter)' -d '{"analysis":  
{"analyzer": {"default": {"type": "english"}}}}'  
curl -XPUT [http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1) -d '{"title": "User  
setting"}'  
curl -XPOST [http://localhost:9200/twitter/\_refresh](http://localhost:9200/twitter/_refresh)

# the following match; good

curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
-d '{"text": {"\_all": "setting"}}'  
curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
-d '{"text": {"\_all": "settings"}}'

curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
-d '{"prefix": {"\_all": "s"}}'  
curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
-d '{"prefix": {"\_all": "se"}}'  
curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
-d '{"prefix": {"\_all": "set"}}'

# the following don't match; not good

curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
-d '{"prefix": {"\_all": "sett"}}'  
curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
-d '{"prefix": {"\_all": "setting"}}'

Is there a way to make it work as desired without a second index?

Thanks,  
George

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [July 20, 2012, 3:44pm UTC](https://discuss.elastic.co/t/disable-custom-analyzer-for-prefix-filter/8466/2 "2012-07-20T15:44:56Z")

</div>

On Thursday, July 19, 2012 5:01:34 PM UTC+2, George Sakkis wrote:

> Hi all,
> 
> I have defined a custom default analyzer that works fine for "text"  
> and "string\_query" type queries but is problematic for prefix filters.  
> Here is a simpler example using the "english" analyzer:
> 
> curl -XPUT '[http://localhost:9200/twitter](http://localhost:9200/twitter)' -d '{"analysis":  
> {"analyzer": {"default": {"type": "english"}}}}'  
> curl -XPUT [http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1) -d '{"title": "User  
> setting"}'  
> curl -XPOST [http://localhost:9200/twitter/\_refresh](http://localhost:9200/twitter/_refresh)
> 
> # the following match; good
> 
> curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> -d '{"text": {"\_all": "setting"}}'  
> curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> -d '{"text": {"\_all": "settings"}}'
> 
> curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> -d '{"prefix": {"\_all": "s"}}'  
> curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> -d '{"prefix": {"\_all": "se"}}'  
> curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> -d '{"prefix": {"\_all": "set"}}'
> 
> # the following don't match; not good
> 
> curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> -d '{"prefix": {"\_all": "sett"}}'  
> curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> -d '{"prefix": {"\_all": "setting"}}'
> 
> Is there a way to make it work as desired without a second index?

the english analyzer uses a stemmer that stems "setting" to set. If you use  
prefix query no analysis is applied that is why sett and setting  
respectively doesn't match anything. I'd actually argue that you need  
prefix matching if you are already stemming. Yet, in your example you might  
not want to stemm at all but I know almost nothing about your search  
scenario. Can you provide more infos about waht you are trying to do?

simon

> Thanks,  
> George

---

<div class="post-metadata">

**Author:** ![George\_Sakkis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/george_sakkis/32/2801_2.png) [@George\_Sakkis](https://discuss.elastic.co/u/George_Sakkis)\
**Post date:** [July 21, 2012, 1:52pm UTC](https://discuss.elastic.co/t/disable-custom-analyzer-for-prefix-filter/8466/3 "2012-07-21T13:52:18Z")

</div>

On Friday, July 20, 2012 5:44:56 PM UTC+2, simonw wrote:

> On Thursday, July 19, 2012 5:01:34 PM UTC+2, George Sakkis wrote:
> 
> > Hi all,
> > 
> > I have defined a custom default analyzer that works fine for "text"  
> > and "string\_query" type queries but is problematic for prefix filters.  
> > Here is a simpler example using the "english" analyzer:
> > 
> > curl -XPUT '[http://localhost:9200/twitter](http://localhost:9200/twitter)' -d '{"analysis":  
> > {"analyzer": {"default": {"type": "english"}}}}'  
> > curl -XPUT [http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1) -d '{"title": "User  
> > setting"}'  
> > curl -XPOST [http://localhost:9200/twitter/\_refresh](http://localhost:9200/twitter/_refresh)
> > 
> > # the following match; good
> > 
> > curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> > -d '{"text": {"\_all": "setting"}}'  
> > curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> > -d '{"text": {"\_all": "settings"}}'
> > 
> > curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> > -d '{"prefix": {"\_all": "s"}}'  
> > curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> > -d '{"prefix": {"\_all": "se"}}'  
> > curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> > -d '{"prefix": {"\_all": "set"}}'
> > 
> > # the following don't match; not good
> > 
> > curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> > -d '{"prefix": {"\_all": "sett"}}'  
> > curl -s -XGET '[http://localhost:9200/twitter/tweet/\_count?pretty=true](http://localhost:9200/twitter/tweet/_count?pretty=true)'  
> > -d '{"prefix": {"\_all": "setting"}}'
> > 
> > Is there a way to make it work as desired without a second index?
> 
> the english analyzer uses a stemmer that stems "setting" to set. If you  
> use prefix query no analysis is applied that is why sett and setting  
> respectively doesn't match anything. I'd actually argue that you need  
> prefix matching if you are already stemming. Yet, in your example you might  
> not want to stemm at all but I know almost nothing about your search  
> scenario. Can you provide more infos about waht you are trying to do?
> 
> simon

Basically there are two scenarios. Prefix filtering is used for updating a  
live list of matches as a user is typing in a search box one character at a  
time. In this scenario I don't want any analyzer to be applied as the query  
is not fully formed yet. In the other scenario the query is finalized and I  
want to use a custom analyzer for stemming, stoplisting and whatnot.

George

---

<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:19am UTC](https://discuss.elastic.co/t/disable-custom-analyzer-for-prefix-filter/8466/4 "2017-07-06T03:19:32Z")

</div>


