MySQL的全文搜索布尔模式部分匹配 [英] MySQL Full Text Search Boolean Mode Partial Match

查看:382
本文介绍了MySQL的全文搜索布尔模式部分匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现MySQL的全文搜索有用的布尔模式,但有似乎一对夫妇的事情我无法弄清楚如何实现的。

I've found boolean mode of MySQL full text search useful, however there are a couple of things I can't seem to figure out how to achieve.

例如假设我有含有史蒂夫的JavaScript教程 - 第一部分全文列。

For instance imagine I have a full text column containing the words "Steve's Javascript Tutorial - Part One".

我想匹配这个以下每个搜索:教程,javascript教程,Java的,Java脚本,脚本

I would like to match this for each of the following searches: "tutorials", "javascript tutorials", "java", "java script", "script"

试想一下,其中每个搜索只是分配到任何可使用的语言(我都是用PHP)。

Imagine that each of those searches is simply assigned to a variable in whatever language may be being used (I always use PHP).

我怎么能修改此确保史蒂夫的文章是对其中每个搜索返回的?

How could I modify this to make sure that Steve's article is returned on each of those searches?

MATCH(ARTICLE_TITLE)AGAINST('+ $变量+*IN BOOLEAN MODE)

MATCH (article_title) AGAINST ('"+$variable+"*' IN BOOLEAN MODE)

推荐答案

这是不可能的;)

当你搜索教程下的条目不会被发现,因为在数据库中的条目是单数和搜索词是复数。你应该做某种形式的词干插入值到数据库中(以及搜索)之前。

When you search for "tutorials" the entry will not be found, because the entry in the database is singular and the search term is plural. You should do some form of "word stemming" before inserting the values to the database (and on search).

当你这样做,你的前pression会工作。对于有多个字(空格)searrch条款则应将星号添加到每一个字。

When you have done this, your expression will work. For searrch terms with more words (spaces) you should add the asterix to every word.

这篇关于MySQL的全文搜索布尔模式部分匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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