我如何在索引中搜索拼写错误的单词?(How can I search for misspelled words on my index?)

编程入门 行业动态 更新时间:2024-10-28 19:33:36
我如何在索引中搜索拼写错误的单词?(How can I search for misspelled words on my index?)

我正在构建遵循此工作流程的监控Web应用程序:

一个品牌的(沃尔沃,宝马等)社交账户,这个例子的facebook,链接到应用程序,所有信息(评论,反应,帖子)被检索并保存到本地数据库。

统计信息会生成并显示在内部仪表板上。

然后,用户可以从此仪表板中搜索包含特定单词的帖子或评论。

我在搜索表单上使用Select2,只允许用户搜索单个词,即。 [坏,汽车,服务]。

使用mySQL搜索的一个简单的实现已经被部署,并且我自从与Elastic Search合作以获得更好的解决方案。

所以我的问题是:

在本地数据库中,我有5条记录,其中包含:

“这辆车真的很糟糕” “这辆车真是太棒了” “这辆车真的很放心” “这辆车真的很脆弱” “这辆车真是太棒了”

当用户搜索“糟糕的”时,如何获取所有这些记录?

我一直在尝试用他们的文档中的短语建议示例,但没有任何运气。

谢谢。

I'm building a monitoring web app that follows this workflow:

A brand's (volvo, bmw, etc) social account, facebook for this example, is linked to the app and all the info (comments, reactions, posts) is retrieved and saved to a local DB.

Stats are generated and displayed on an internal dashboard.

Users can then search from this dashboard for posts or comments containing certain words.

I am using Select2 on the search form and only allowing users to search for individual words ie. [bad, car, service].

A simple implementation using mySQL search has already been deployed and I am since working with Elastic Search for a better solution.

So my question is:

On the local database I have 5 records containing:

"This car is really awful" "This car is really awfeul" "This car is really waful" "This car is really awfful" "This car is really awfull"

How can I get all this records back when the user searches for "awful"

I have been trying with the phrase suggest example on their documentation without any luck.

Thanks.

最满意答案

请看看模糊性或模糊查询 。 应该对你有帮助。

您可以使用match查询进行fuzziness = AUTO :

GET /_search { "query": { "match" : { "your_field_name" : { "query" : "awful", "fuzziness": "AUTO" } } } }

如果AUTO不够,你可以在文档中指定参数。

Please, take a look on fuzziness or fuzzy query. Should be helpful for you.

You can use match query for with fuzziness = AUTO:

GET /_search { "query": { "match" : { "your_field_name" : { "query" : "awful", "fuzziness": "AUTO" } } } }

if AUTO is not sufficient you can specify the param base on documentation.

更多推荐

本文发布于:2023-08-02 17:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1378283.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单词   索引   错误   如何在   words

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!