# Best way to get exact matches in query string searches, while also using a stemmer

**URL:** https://discuss.elastic.co/t/best-way-to-get-exact-matches-in-query-string-searches-while-also-using-a-stemmer/23135
**Category:** Elasticsearch
**Created:** [April 7, 2015, 5:57pm UTC](https://discuss.elastic.co/t/best-way-to-get-exact-matches-in-query-string-searches-while-also-using-a-stemmer/23135 "2015-04-07T17:57:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Tom\_Weingarten](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@Tom\_Weingarten](https://discuss.elastic.co/u/Tom_Weingarten)
#### Post date: [April 7, 2015, 5:57pm UTC](https://discuss.elastic.co/t/best-way-to-get-exact-matches-in-query-string-searches-while-also-using-a-stemmer/23135/1 "2015-04-07T17:57:48Z")

</div>

Hi,

In my current setup, I use a stemmer to analyze a field called summary. The  
user is able to search over the summary field using full lucene syntax,  
which we pass directly to elasticsearch through a query\_string query,  
inside a filter. We always sort results based on their date field, so we  
use a constant score.

Unfortunately, our use of the stemmer has problems when users search for  
phrases in quotations. For instance, a search for "Crowd Valley" returns  
hits for the phrase "crowded valley". Ideally, I'd like to be able to  
ignore the stemmer for the portion of a query in a quoted phrase, but use  
the stemmer for all parts of the query outside of quotes.

Is such a thing in possible for ElasticSearch? If not, does anyone have any  
best practices for getting close to this behavior as possible?

Our current best idea is to use a multi\_field with two analyzers - one with  
a stemmer, one without a stemmer. This would allow us to search either one  
or the other, depending on if the user has a quotation mark present in  
their query. However this would not be ideal for mixed queries such as:  
"Crowd Valley" or running clubs [because the running clubs part would not  
be stemmed]

Many thanks,  
Tom Weingarten  
CTO & Co-founder, Wiser

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/88e6b645-73e5-4bca-9b99-082fcdc2c655%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/88e6b645-73e5-4bca-9b99-082fcdc2c655%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:21am UTC](https://discuss.elastic.co/t/best-way-to-get-exact-matches-in-query-string-searches-while-also-using-a-stemmer/23135/2 "2017-07-06T00:21:03Z")

</div>


