Fuzziness functionality not working for single word in my searchasyoutype datatype field query elasticsearch nest?

百般思念 提交于 2020-01-06 05:29:08

问题


I am using nest api and searchasyoutype datatype but the fuziness(Fuzziness.Auto) is not working Following is my code:

var searchResponse=_con.client.Search<object>(x=>x.Index("_all").Query(q=>q.MultiMatch(m=>m.Query(searchterm)                                                                                                    
                                                                      .Fuzziness(Fuzziness.Auto)                                                                                                               
                                                                      .Fields(f => f.Field("name").Field("name._2gram").Field("name._3gram"))                                                                                                                                                                                                                    
                                                                      .Type(TextQueryType.BoolPrefix)                                                                                                             
                                                                       )));

Following result is when searchterm is correctly spelled with searchterm=washing

https://localhost:44311/api/search/suggest/?searchterm=Washing&indexname=test3

Output:

[
    {
        "id": "4",
        "description": "Top load Washing Machine",
        "name": "Whirlpool 8kg load washing machine",
        "qty": "100"
    }
]

But when i do with searchterm= wafhing it displays no result

https://localhost:44311/api/search/suggest/?searchterm=Wafhing&indexname=test3

Output

[]

and when search term contains two mispelled words i get the expected output:

https://localhost:44311/api/search/suggest/?searchterm=wasing achene&indexname=test3

Output:

[
    {
        "id": "4",
        "description": "Top load Washing Machine",
        "name": "Whirlpool 8kg load washing machine",
        "qty": "100"
    }
]

来源:https://stackoverflow.com/questions/59574757/fuzziness-functionality-not-working-for-single-word-in-my-searchasyoutype-dataty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!