Elasticsearch-dsl-py: How can I add fuzziness for Q

Created on 27 Jul 2018  路  1Comment  路  Source: elastic/elasticsearch-dsl-py

query = Q("nested", path="text", score_mode="max", ignore_unmapped=True, query=Q("match", **{"text.lyric": value}))

Now I want to construct a query, How can I add parameter fuzziness to the above code?
thanks ahead

Most helpful comment

query = Q("nested", path="text", score_mode="max", ignore_unmapped=True, query=Q("match", text__lyric={"query": value, "fuzziness": 1}))

should do the trick. Essentially always take the json from the documentation (0) and translate the top level keys to keyword arguments. In this case you can also use __ instead of . to avoida having to do the **{} construct.

Hope this helps!

0 - https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-fuzziness

>All comments

query = Q("nested", path="text", score_mode="max", ignore_unmapped=True, query=Q("match", text__lyric={"query": value, "fuzziness": 1}))

should do the trick. Essentially always take the json from the documentation (0) and translate the top level keys to keyword arguments. In this case you can also use __ instead of . to avoida having to do the **{} construct.

Hope this helps!

0 - https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-fuzziness

Was this page helpful?
0 / 5 - 0 ratings

Related issues

njoannin picture njoannin  路  3Comments

takaomag picture takaomag  路  3Comments

vmogilev picture vmogilev  路  4Comments

mortada picture mortada  路  3Comments

ypkkhatri picture ypkkhatri  路  4Comments