2

我可以在/foo中使用 match来搜索行:barcol1col2

SELECT col1, col2
FROM some_table
WHERE MATCH (col1,col2)
      AGAINST ('+foo +bar' IN BOOLEAN MODE);

但是假设我想搜索确切的短语“foo.bar” (中间有句号)。在Boolean Full-Text Searches 的文档页面上,它没有提到句号是运算符,所以我想我可以使用:

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

.

为什么这不像我预期的那样工作?我该如何匹配 for foo.bar

4

2 回答 2

1

我没有现成的全文表来测试这一点,但我相信这应该可行:

SELECT col1, col2
FROM some_table
WHERE MATCH (col1,col2)
    AGAINST ('+\"foo.bar\"' IN BOOLEAN MODE);
于 2012-08-22T15:48:25.603 回答
1

要完成这项工作,您需要用双引号将您的文字括起来:"bar.foo",因为该点可能等同or运算符。

于 2012-08-22T16:02:01.017 回答