MySQL全文布尔NOT运算符 [英] mysql fulltext boolean NOT operator

查看:161
本文介绍了MySQL全文布尔NOT运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以布尔模式进行MySQL FULLTEXT搜索.根据手册:

I'm doing a MySQL FULLTEXT search in boolean mode. According to the manual :

Note: The - operator acts only to exclude rows that are otherwise 
matched by  other search terms. Thus, a boolean-mode search that 
contains only terms preceded by - returns an empty result. It 
does not return "all rows except those containing any of the 
excluded terms."

是的.

所以我这样使用NOT MATCH运算符:

So I use the NOT MATCH operator like this :

SELECT COUNT(*) FROM Table WHERE MATCH (Column) AGAINST 
('bar' IN BOOLEAN MODE) AND NOT MATCH (Column) AGAINST 
('barbar' IN BOOLEAN MODE);

我的问题是:NOT匹配字段中+运算符的作用是什么

My question is: what is the effect of the + operator in the NOT MATCH field: is

AND NOT MATCH (Column) AGAINST ('foo bar' IN BOOLEAN MODE)

与:

AND NOT MATCH (Column) AGAINST ('+foo +bar' IN BOOLEAN MODE)

谢谢

推荐答案

+运算符表示存在搜索文字.根据 MySQL文档

+ operator signifies that the search literal is present. Per MySQL Documentation

MySQL可以使用IN BOOLEAN MODE执行布尔全文搜索 修饰符.使用此修饰符,某些字符具有特殊含义 在搜索字符串中单词的开头或结尾处.在里面 查询后, + -运算符表示一个单词是 必须分别存在或不存在

MySQL can perform boolean full-text searches using the IN BOOLEAN MODE modifier. With this modifier, certain characters have special meaning at the beginning or end of words in the search string. In the following query, the + and - operators indicate that a word is required to be present or absent, respectively,

例如,下面的查询将检索包含单词MySQL但不包含单词YourSQL

For example, below query will retrieves all the rows that contain the word MySQL but that do not contain the word YourSQL

SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);

+ 前导加号表示该单词必须出现在每个单词中 返回的行.

+ A leading plus sign indicates that this word must be present in each row that is returned.

WHERE NOT MATCH (column) AGAINST ('+foo +bar' IN BOOLEAN MODE)应该意味着让我获得column值不是foobar的所有行.它应该是WHERE MATCH (column) AGAINST ('+foo +bar' IN BOOLEAN MODE)

WHERE NOT MATCH (column) AGAINST ('+foo +bar' IN BOOLEAN MODE) should mean get me all the rows where values of column isn't foo and bar. it should be a negation of WHERE MATCH (column) AGAINST ('+foo +bar' IN BOOLEAN MODE)

是的,两者都不相同.

WHERE MATCH (column) AGAINST ('+foo +bar' IN BOOLEAN MODE)

获取所有列的值为foo和bar的行

Says that get all rows where values of column are foo and bar

WHERE MATCH (column) AGAINST ('foo bar' IN BOOLEAN MODE)

获取所有列的值为foo或bar的行

Says that get all rows where values of column are foo or bar

仔细检查文档.它说

[无运算符]表示或"

[no operator] implies OR

[+]表示AND

这篇关于MySQL全文布尔NOT运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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