在MySQL全文搜索中处理拼写错误的最佳方法 [英] Best way to deal with misspellings in a MySQL fulltext search

查看:88
本文介绍了在MySQL全文搜索中处理拼写错误的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mysql数据库中有大约2000行。

I have about 2000 rows in a mysql database.

每行最多300个字符,包含一两个句子。

Each row is a max of 300 characters and contains a sentence or two.

我使用内置全文搜索的mysql来搜索这些行。

I use mysql's built in fulltext search to search these rows.

我想添加一个功能,以便纠正拼写错误和意外错误拼写,如果可能的话。

I would like to add a feature so that typos and accidental mispellings are corrected, if possible.

例如,如果有人在搜索框中键入right shlder,则执行搜索时,这将等同于右肩。

For example, if someone types "right shlder" into the searchbox, this would equate to "right shoulder" when performing the search.

对于添加这种功能最简单的方法,您有哪些建议?是否值得添加某种外部搜索引擎,如lucene? (看起来对于这样一个小数据集来说,这太过分了)。或者有一个更简单的方法吗?

What are your suggestions on the simplest way to add this kind of functionality? Is it worth adding an external search engine of some kind, like lucene? (It seems like for such a small dataset, this is overkill.) Or is there a simpler way?

感谢(提前)寻求帮助。

Thanks (in advance) for your help.

推荐答案

我想你应该使用 SOUNDS LIKE SOUNDEX )

由于您的数据集非常小,因此一种解决方案可能是创建一个新表来存储单个单词或soundex值每个文本字段并在该表上使用SOUNDS LIKE。

As your data set is so small, one solution may be to create a new table to store the individual words or soundex values contained in each text field and use SOUNDS LIKE on that table.

例如:

e.g:

SELECT * FROM table where id IN 
(
    SELECT refid FROM tableofwords 
    WHERE column SOUNDS LIKE 'right' OR column SOUNDS LIKE 'shlder'
)

请参阅: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

我相信这是不可能的通配符字符串:(

I belive it is not possible to wild card seach the string :(

这篇关于在MySQL全文搜索中处理拼写错误的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆