本文介绍了prepending *(星号),以一个全文检索在MySQL中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,星号是可以附加到全文检索词的结尾通配符,但如果我搜索的关键词是什么后缀?例如,我希望能够搜索埃姆斯,并有包含詹姆斯返回的名称的结果。这里是我当前的查询不工作,因为你不能prePEND星号搜索全文

I understand that the asterisk is a wildcard that can be appended to the end of fulltext search words, but what if my searched keyword is a suffix? For example, I want to be able to search for "ames" and have a result that contains the name "james" returned. Here is my current query which does not work because you cannot prepend asterisks to fulltext searches.

SELECT * FROM table WHERE MATCH(name, about, address) AGAINST ("*$key*" IN BOOLEAN MODE)

我想简单地切换到使用等,但将是我的数据库大小的方式太慢了。

I would simply switch to using LIKE, but it would be way too slow for the size of my database.

推荐答案

无法做到,由于MySQL的限制。值被索引左到右,不对到左。你必须与LIKE坚持,如果你想通配符prepended搜索字符串。

Can't be done due to limitation of MySQL. Values are indexed left-to-right, not right-to-left. You'll have to stick with LIKE if you want wildcards prepended to search string.

这篇关于prepending *(星号),以一个全文检索在MySQL中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 05:43