Elasticsearch: Fuzziness does not works with query string in elasticsearch

Created on 13 Mar 2018  路  2Comments  路  Source: elastic/elasticsearch

Describe the feature:

Elasticsearch version (bin/elasticsearch --version):
6.2
Plugins installed: []

JVM version (java -version):

OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:
I've got some query

{ type: 'Wandering',
   zone: '1',
   personName: 'Dmytro',
   personRoom: 'Room_73' } }

And use wildcard and fuzziness with a query string, but looks like, when I type Wandring or wadnering , I expected fuzziness makes replacement.

'query': {
                    'query_string' : {
                        'query': `*${search}*~1 OR *${search}~1`,
                        'analyze_wildcard': true,
                    },
                }

Provide logs (if relevant):

:SearcSearch >bug

Most helpful comment

The query_string cannot mix wildcards with fuzziness. You can search for wandring~1 but not wandring*~1. If you want to mix prefix search and fuzziness you can use the completion field in a suggest query or use an analyzer that builds all prefix/suffix of the terms at index time (https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-ngram-tokenizer.html) so that you can query an exact term (with fuzziness if needed) and get all suffixes/prefixes at query time.

All 2 comments

Pinging @elastic/es-search-aggs

The query_string cannot mix wildcards with fuzziness. You can search for wandring~1 but not wandring*~1. If you want to mix prefix search and fuzziness you can use the completion field in a suggest query or use an analyzer that builds all prefix/suffix of the terms at index time (https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-ngram-tokenizer.html) so that you can query an exact term (with fuzziness if needed) and get all suffixes/prefixes at query time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clintongormley picture clintongormley  路  3Comments

dadoonet picture dadoonet  路  3Comments

Praveen82 picture Praveen82  路  3Comments

brwe picture brwe  路  3Comments

ttaranov picture ttaranov  路  3Comments