sql MATCH AGAINST BOOLEAN MODE 返回 0 个结果

发布于 2024-12-10 01:08:13 字数 2270 浏览 1 评论 0原文

这是查询:

SELECT title from prod_table WHERE MATCH(title) AGAINST ('-Gears Of War' IN BOOLEAN MODE) limit 30;

表肯定已填充,这里是模式

SQL query: explain prod_table;
Rows: 22
Field           Type        Null        Key     Default     Extra
PRprodinfo_id   int(11)     NO          PRI     NULL    auto_increment
PRid            varchar(64) NO  UNI     NULL    
main_category   varchar(64) YES         NULL    
title           varchar(128)NO  MUL     NULL    
agegroup        varchar(16) YES         NULL    
author          varchar(128)YES         NULL    
sex             varchar(8)  YES         NULL    
actors          varchar(256)YES         NULL    
platform        varchar(64) YES         NULL    
artist          varchar(128)YES         NULL    
genre           varchar(128)YES         NULL    
description     text        YES         NULL    
manuf           varchar(128)YES         NULL    
manufID         varchar(64) YES         NULL    
prodcat         varchar(128)YES         NULL    
prodcatID       int(11)     YES         NULL    
userrating      decimal(1,1)NO      NULL    
profrating      decimal(1,1)NO      NULL    
lowprice        decimal(10,2)   NO      NULL    
highprice       decimal(10,2)   NO      NULL    
imageURL        varchar(128)    NO      NULL    
dateadded       timestamp       NO      CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

也尝试过:

SELECT title from PRprodINFO WHERE MATCH(title) AGAINST ("-'Gears Of War'" IN BOOLEAN MODE) limit 30;

SELECT title from PRprodINFO WHERE MATCH(title) AGAINST ("'-Gears Of War'" IN BOOLEAN MODE) limit 30;

它们有点取消自己,一些结果是:

'Gears and Gear Cutting Workshop Practice'
'Gears of War 2 Signature Series Guide Bradygames Signature Guides'
'Gears of War 2 Last Stand Edition Guide Bradygames Signature'
'Cream  Disraeli Gears  Classic Albums DVD RETAIL BUT NOT AVAILABLE TO RENT'
'Gears of War 2 Limited Edition'
'Gears Of War'
'Gears of War 2'
'Gears of War Triple Pack'
'Gears of War 2 Game of the Year Edition'
'Gears of War 3 Limited Edition'
'Gears of War 3'

这正是我不想要的

我被难住了 - 而且,在title 字段有一个 FULLTEXT 索引。

谢谢达伦

This is the query:

SELECT title from prod_table WHERE MATCH(title) AGAINST ('-Gears Of War' IN BOOLEAN MODE) limit 30;

The table is definitely populated and here is schema

SQL query: explain prod_table;
Rows: 22
Field           Type        Null        Key     Default     Extra
PRprodinfo_id   int(11)     NO          PRI     NULL    auto_increment
PRid            varchar(64) NO  UNI     NULL    
main_category   varchar(64) YES         NULL    
title           varchar(128)NO  MUL     NULL    
agegroup        varchar(16) YES         NULL    
author          varchar(128)YES         NULL    
sex             varchar(8)  YES         NULL    
actors          varchar(256)YES         NULL    
platform        varchar(64) YES         NULL    
artist          varchar(128)YES         NULL    
genre           varchar(128)YES         NULL    
description     text        YES         NULL    
manuf           varchar(128)YES         NULL    
manufID         varchar(64) YES         NULL    
prodcat         varchar(128)YES         NULL    
prodcatID       int(11)     YES         NULL    
userrating      decimal(1,1)NO      NULL    
profrating      decimal(1,1)NO      NULL    
lowprice        decimal(10,2)   NO      NULL    
highprice       decimal(10,2)   NO      NULL    
imageURL        varchar(128)    NO      NULL    
dateadded       timestamp       NO      CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

Also tried:

SELECT title from PRprodINFO WHERE MATCH(title) AGAINST ("-'Gears Of War'" IN BOOLEAN MODE) limit 30;

and

SELECT title from PRprodINFO WHERE MATCH(title) AGAINST ("'-Gears Of War'" IN BOOLEAN MODE) limit 30;

but they kind of cancel themselves out, some of the reults are:

'Gears and Gear Cutting Workshop Practice'
'Gears of War 2 Signature Series Guide Bradygames Signature Guides'
'Gears of War 2 Last Stand Edition Guide Bradygames Signature'
'Cream  Disraeli Gears  Classic Albums DVD RETAIL BUT NOT AVAILABLE TO RENT'
'Gears of War 2 Limited Edition'
'Gears Of War'
'Gears of War 2'
'Gears of War Triple Pack'
'Gears of War 2 Game of the Year Edition'
'Gears of War 3 Limited Edition'
'Gears of War 3'

Which is exactly what i DON'T want

I'm stumped - also, on the title field there is a FULLTEXT index.

Thanks

Darren

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

辞旧 2024-12-17 01:08:13

试试这个:

SELECT title from prod_table WHERE MATCH(title) AGAINST ( "-'Gears Of War'" IN BOOLEAN MODE) limit 30;

在单词两边加上单引号。

Try this:

SELECT title from prod_table WHERE MATCH(title) AGAINST ( "-'Gears Of War'" IN BOOLEAN MODE) limit 30;

with single quotes around the words.

眼泪都笑了 2024-12-17 01:08:13

不支持使用单个否定查询。阅读文档。它指出:

注意:- 运算符仅用于排除其他行
与其他搜索词相匹配。因此,布尔模式搜索
仅包含以 - 开头的术语,返回空结果。它不
返回“除包含任何排除术语的行之外的所有行。”

所以这是不可能的。您必须包含其他内容供查询查找,以排除与 - 匹配的行。

这只是我的意见,但我认为尝试返回与某些任意术语不匹配的所有行的列表太过密集。最好的解决方案是使用“like”查询,如下所示。

SELECT title from prod_table 
WHERE NOT title LIKE '%Gears Of War%' 
limit 30;

Using a single negation query isn't supported. Read the documentation. It states:

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.”

So this is not possible. You must include something else for the query to find, to exclude the rows matched with the -.

Just my opinion here, but I think it would be way too intensive to try to return a list of all rows that doesn't match some arbitrary term. The best solution would be to use a "like" query as follows.

SELECT title from prod_table 
WHERE NOT title LIKE '%Gears Of War%' 
limit 30;
一指流沙 2024-12-17 01:08:13

您将无法使用 MATCH AGAINST 运算符来解决此问题。解决方案是 否定 LIKE< /a> 查询。例如:

SELECT title FROM prod_table WHERE title NOT LIKE '%Gears Of War%' LIMIT 30;

You won't be able to solve this problem using MATCH AGAINST operator. A solution would be to negate a LIKE query. E.g:

SELECT title FROM prod_table WHERE title NOT LIKE '%Gears Of War%' LIMIT 30;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文