开发者

Boolean search with truncated exclutions words don't work for me

开发者 https://www.devze.com 2023-03-13 22:26 出处:网络
When I search for: SELECT * FROM db.test WHERE MATCH(story)AGAINST(\'(+bananas -banana*)\'IN BOOLEAN MODE)

When I search for:

SELECT * FROM db.test
WHERE
MATCH(story)AGAINST('(+bananas -banana*)'IN BOOLEAN MODE)

I get rows returned but when I search for

SELECT * FROM db.test
WHERE
MATCH(story)AGAINST('(+bananas -bananas)'IN BOOLEAN MODE)

or

SELECT * FROM db.test
WHERE
MATCH(story)AGAINST('(+bananas -bananas*)'IN BOOLEAN MODE)

I get no result. To 开发者_StackOverflowme it seems like you can´t use * together with the minus sign. Does anybody know if thats the case or if its a setting in MySql.

Kind regards Olle

The table is MYISAM and I have a index on the column story.


The last 2 queries do not give any result because they contain contradicting conditions - story must have the word "bananas" and must not have the word "bananas". This is not possible and hence no results.

However the first query means that "bananas" must be present but no "banana".

Also, you may use * with the minus operator.

Hope this helps.


The solution is to skip the parentheses. If I search for '+bananas -banana*' instead of '(+bananas -banana*)' it works. It took a while to figure out thou.

Cheers

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号