本文介绍了带茎的MySQL全文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的网站建立一个小搜索功能。我正在接受用户的查询,填充关键字,然后针对词干关键字运行全文MySQL搜索。



问题是MySQL将词干视为文字。以下是正在发生的流程:用户搜索baseballs之类的字词
$ b


  1. 我的词干算法(Porter Stemmer)将棒球变成了basebal。即使应该匹配棒球和棒球,全文也找不到匹配basebal的任何内容,

$ LIKE'basebal%'等同于全文吗?



这是我目前的查询: SELECT MATCH('title`,`body`)AGAINST('basebal')AS`related`,`id` FROM`blogs` WHERE MATCH(`title`,`body`)AGAINST('basebal')ORDER BY`relevance `DESC


解决方案

我认为它会在星号最后: basebal * 。请参阅获取更多信息。


I am building a little search function for my site. I am taking my user's query, stemming the keywords and then running a fulltext MySQL search against the stemmed keywords.

The problem is that MySQL is treating the stems as literal. Here is the process that is happening:

  1. user searches for a word like "baseballs"
  2. my stemming algorithm (Porter Stemmer) turns "baseballs" into "basebal"
  3. fulltext does not find anything matching "basebal", even though there SHOULD be matches for "baseball" and "baseballs"

How do I do the equivalent of LIKE 'basebal%' with fulltext?

EDIT:

Here is my current query:

SELECT MATCH (`title`,`body`) AGAINST ('basebal') AS `relevance`,`id` FROM `blogs` WHERE MATCH (`title`,`body`) AGAINST ('basebal') ORDER BY `relevance` DESC
解决方案

I think it will work with an asterisk at the end: basebal*. See the * operator on this page for more info.

这篇关于带茎的MySQL全文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 10:31