How to remove fuzziness in Simple Query String?

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
            )

    )

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

@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.

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

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.

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?

into the search request body.

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 );

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