Match against “foo.bar” (with a full-stop/period)

此生再无相见时 提交于 2019-12-11 05:45:44

问题


I can search for rows with both foo and bar in the col1/col2 using match against:

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

But suppose I want to search for the exact phrase "foo.bar" (with a full-stop in the middle). On the docs page for Boolean Full-Text Searches, it doesn't mention full-stop being an operator, so I thought I could use:

AGAINST ('+foo.bar' IN BOOLEAN MODE);

However, this returns the same results as:

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

.

Why isn't this working as I expect? and how can I match against for foo.bar?


回答1:


I don't have a fulltext table readily available to test this out, but I believe this should work:

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



回答2:


To make this work, you need to suround your literal by a double quote: "bar.foo", because the point is probably equivalent to or operator.



来源:https://stackoverflow.com/questions/12076780/match-against-foo-bar-with-a-full-stop-period

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!