我可以在col1
/col2
中使用match-and-:搜索同时具有foo
和bar
的行
SELECT col1, col2
FROM some_table
WHERE MATCH (col1,col2)
AGAINST ('+foo +bar' IN BOOLEAN MODE);
但假设我想搜索确切的短语"strong";foo.bar"(中间有一个完整的顶部)。在布尔全文搜索的文档页面上,它没有提到句号是一个运算符,所以我想我可以使用:
AGAINST ('+foo.bar' IN BOOLEAN MODE);
然而,这返回的结果与以下相同:
AGAINST ('+foo.couldBeAnything' IN BOOLEAN MODE);
AGAINST ('+foo' IN BOOLEAN MODE);
AGAINST ('+foo.*' IN BOOLEAN MODE); #Note you would expect this to look for instances of foo. followed by something, rather than just the same as foo
为什么这没有像我预期的那样起作用?对于foo.bar
,我该如何与之匹配?
我没有现成的全文表来测试这一点,但我相信这应该有效:
SELECT col1, col2
FROM some_table
WHERE MATCH (col1,col2)
AGAINST ('+"foo.bar"' IN BOOLEAN MODE);
要实现这一点,您需要在文字后面加一个双引号:"bar.foo",因为点是可能等价于或运算符。