匹配“foo.bar"(有句号/句号) [英] Match against "foo.bar" (with a full-stop/period)

查看:70
本文介绍了匹配“foo.bar"(有句号/句号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用匹配来搜索 col1/col2 中同时包含 foobar 的行:

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);

但假设我想搜索确切的短语 "foo.bar" (中间有句号).在 布尔全文搜索的文档页面,它没有提到句号是一个操作员,所以我想我可以使用:

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

.

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

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

推荐答案

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

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);

这篇关于匹配“foo.bar"(有句号/句号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆