# How to remove fuzziness in Simple Query String?

**URL:** <https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078>\
**Category:** Elasticsearch\
**Created:** [February 20, 2020, 4:46am UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078 "2020-02-20T04:46:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [February 20, 2020, 4:46am UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/1 "2020-02-20T04:46:21Z")

</div>

I am trying to disable fuzziness in my ElasticSearch query. The issue is that a search for _medication_ returns lots of hits for _medical_. My query is below. The fuzzy\_max\_expansions arg doesn't have any effect. If I add a fuzziness arg it breaks the query altogether.

I am using Wordpress and Elasticpress to query elasticsearch.

```
[query] => Array
    (
        [simple_query_string] => Array
            (
                [query] => medication
                [fields] => Array
                    (
                        [0] => post_title
                        [1] => post_excerpt
                        [2] => post_content
                    )

                [default_operator] => and
                [flags] => all
                [fuzzy_transpositions] => false
                [fuzzy_max_expansions] => 0
            )

    )
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 20, 2020, 8:14am UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/2 "2020-02-20T08:14:25Z")

</div>

See the LIMIT operators of the simple query string, [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html#supported-flags](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html#supported-flags)

---

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [February 20, 2020, 1:47pm UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/3 "2020-02-20T13:47:14Z")

</div>

@spinscale  
Setting the flags to AND|OR|PHRASE does not change behavior.  
A search for _medication_ still returns _medical_.  
I am assuming this is a fuzziness effect, but I can't find a way to modify these results.

---

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [February 20, 2020, 1:54pm UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/4 "2020-02-20T13:54:10Z")

</div>

Additionally, if I set flags to ALL, and change the search term to _medication~0_, I still get returns for medical.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 20, 2020, 2:34pm UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/5 "2020-02-20T14:34:42Z")

</div>

can you share fully reproducible example including the mapping. I just want to make sure there is no stemmer involved, that stems the words down to their root forms, which would mean, that each of those terms would match independent from any fuzzy match.

Also adding `explain: true` should give you a first indiccation what terms are actually searched for. Another good hint is to use the analyze API to understand how your terms are modified before being stored.

---

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [February 20, 2020, 8:15pm UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/6 "2020-02-20T20:15:42Z")

</div>

Thanks Alex. This project is behind a firewall, so I don't think you will be able to reproduce it. I will certainly look at the analyzer and see if there is a stemmer involved. Where does explain go?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 21, 2020, 7:53am UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/7 "2020-02-21T07:53:02Z")

</div>

into the search request body.

---

<div class="post-metadata">

**Author:** ![photocurio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photocurio/32/62986_2.png) [@photocurio](https://discuss.elastic.co/u/photocurio)\
**Post date:** [February 22, 2020, 4:31pm UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/8 "2020-02-22T16:31:00Z")

</div>

I solved this by filtering the elasticpress mappings. The issue was the ewp\_snowball filter.  
function remove\_snowball( $mapping ) {  
unset( $mapping['settings']['analysis']['analyzer']['default']['filter'][4] );  
}  
add\_filter( 'ep\_config\_mapping', 'remove\_snowball', 10, 2 );

---

<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:** [March 21, 2020, 4:39pm UTC](https://discuss.elastic.co/t/how-to-remove-fuzziness-in-simple-query-string/220078/9 "2020-03-21T16:39:02Z")

</div>

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