本文介绍了MySQL LIKE%string%不太宽容。还有什么我可以用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户询问他们的搜索是否搜索可以根据用户输入以多种格式搜索的公司名称,例如存储在数据库中的公司是AJR Kelly Ltd,如果是用户搜索AJR Kelly找到,使用;

I've got a client who's asking if their search, which searches for company names which could be searched for in several formats depending on user input, such as the company stored in the database being A J R Kelly Ltd for instance, If a user searches "A J R Kelly" it's found, using;

<cfif pctermsCount gt 0>
AND (LOWER(p.name)  LIKE '%#pcTerms#%')
</cfif>

如果他们搜索Kelly的公司被发现,但如果他们搜索一个破碎的版本

If they search for "Kelly" the company is found, but if they search for a broken version of the string like "A J Kelly" or "AJ Kelly" it's not found.

有没有什么我可以做,只是一点点更宽容?

Is there anything I can do to make it just a little bit more forgiving?

感谢。

推荐答案

如果您使用MyISAM,文本索引。

If you're using MyISAM, you can use full text indexing. See this tutorial

如果您'重新使用不同的存储引擎,则可以使用第三方全文本引擎(如sphinx),该引擎可充当通过索引单词的语音等价物使搜索更宽容,并通过在搜索项上应用SOUNDEX搜索它们,然后使用这些搜索索引来搜索索引。使用soundex mary marie marry ,例如

You can also use SOUNDEX to make searches more forgiving by indexing the phonetic equivalents of words and search them by applying SOUNDEX on your search terms and then using those to search the index. With soundex mary, marie, and marry will all match, for example.

这篇关于MySQL LIKE%string%不太宽容。还有什么我可以用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 20:41