匹配“foo.bar”(带有句号/句号)

时间:2012-08-22 15:43:56

标签: mysql match-against

我可以使用匹配对foo / bar中的col1col2搜索行:

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

但是假设我想要搜索确切的短语“foo.bar” (中间有一个句号)。在the docs page for 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

为什么这不能像我期望的那样工作?以及如何匹配foo.bar

2 个答案:

答案 0 :(得分:1)

我没有现成的全文表来测试这个,但我相信这应该有效:

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

答案 1 :(得分:1)

要做到这一点,你需要用双引号来表达你的文字:“bar.foo”, 因为该点可能等同于 运算符。