Elasticsearch-dsl-py: How to write a fuzzy with query_string

Created on 19 Apr 2021  路  4Comments  路  Source: elastic/elasticsearch-dsl-py

s = Search().query("query_string", query=search_text, fields=['Tittle', 'Description'], default_operator="AND")

I want to add fuzzy to this query

Most helpful comment

Thanks for answering @brainix

All 4 comments

You can use MultiMatch to match multiple fields with the fuzziness parameter like so:

query = MultiMatch(query=search_text, fields=('Title', 'Description'), fuzziness='AUTO')
s = Search().query(query)

Thanks for answering @brainix

Is there anyway to get the word that is being used by elasticearch for searching.
Like elasticsearch will replace "blach jeans" to "black jeans".
So how can I get the phrase/word "black jeans"?

You can use highlighting to see snippets of the fields that matched like so:

query = MultiMatch(query=search_text, fields=('Title', 'Description'), fuzziness='AUTO')
s = Search().query(query).highlight('Title', 'Description', type='plain')
Was this page helpful?
0 / 5 - 0 ratings

Related issues

MauriJHN picture MauriJHN  路  4Comments

quasiben picture quasiben  路  4Comments

primoz-k picture primoz-k  路  4Comments

vanzi picture vanzi  路  4Comments

ypkkhatri picture ypkkhatri  路  4Comments