本文介绍了建议其他查询古式拼字(例如Google的“您是不是要")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户有一个跨越400年的房地产记录数据库.他们有兴趣根据用户的数据向用户提出其他拼写建议.

My client has a database of real estate records spanning 400 years. They are interested to have alternate spelling suggestions made to users based on their data.

我假设在这种情况下,该表将落在一个表上,该表具有用于"Martin"的行以及对"Martyn"和"Martine"的建议等.

I'm assuming in a case like this it would be down to a table that has a rows for "Martin" and suggestions of "Martyn" and "Martine" etc.

有人知道第三方解决方案会为其数据编制索引吗?

Does anyone know of a third party solution which would index their data?

编辑

每个魔术迷的答案SOUNDEX()都吓死了!

Per magicmike's answer SOUNDEX() rocks this!

SELECT `Last` FROM `Names` 
WHERE SOUNDEX(`Last`) RLIKE SOUNDEX ('Martin')
GROUP BY `Last`

产生了这个漂亮的小清单:

yields this nice little list:

Martens
Martenstein
Martin
Martina
Martindale
Martine
Martineau
Martines
Martinet
Martinez
Martini
Martino
Martinstein
Mertens
Miradona
Moret and Marchand
Mortimer
Morton

推荐答案

Google的您的意思是"很有趣:

Google's "did you mean" is pretty interesting: How does the Google "Did you mean?" Algorithm work?

过去,我设法实现了与 SOUNDEX 类似的功能,该功能可以近似该功能.

In the past, I've managed to implement something similar with SOUNDEX which can approximate that functionality.

Martin,Martyn和Martine从SOUNDEX获得相同的输出.

Martin, Martyn, and Martine yield the same output from SOUNDEX.

您可以包括来自SOUNDEX匹配项的所有结果,或者选择他们要求的结果,然后选择select distinct name from table where SOUNDEX(name) = SOUNDEX(search_var)作为您的建议".

You could include all the results from the SOUNDEX match, or select the results they asked for and then select distinct name from table where SOUNDEX(name) = SOUNDEX(search_var) as your 'suggestions'.

作为一种优化,您可以在搜索字段上预先计算SOUNDEX并将其保留为索引列,以避免进行表扫描.

As an optimization, you can pre-calculate SOUNDEX on search fields and persist that as an indexed column to avoid table scans.

它不如Google的《您要说的话》复杂,但是您可以很快地迅速关闭.

It's not as sophisticated as Google's Did You Mean, but you can get reasonably close very quickly.

这篇关于建议其他查询古式拼字(例如Google的“您是不是要")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 12:02