匹配的全程/期间运营商

时间:2022-09-19 17:49:23

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

我可以使用匹配来搜索col1 / col2中foo的所有行:

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

But suppose I want to search for all rows with foo. (i.e. foo with a full-stop as the next character). On the docs page for Boolean Full-Text Searches, it doesn't mention full-stop being an operator, so I thought I could use either of these:

但是假设我想用foo搜索所有行。 (即foo以全停作为下一个字符)。在布尔文全文搜索的文档页面上,它没有提到作为运算符的句号,所以我认为我可以使用以下任何一种:

AGAINST ('foo.' IN BOOLEAN MODE);
AGAINST ('"foo."' IN BOOLEAN MODE);
AGAINST ('"foo\."' 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);

.

What is the . operator in this context? and how can I match-against foo.?

是什么 。在这种情况下运营商?以及如何匹配foo。

Note: I first asked this question about match-against foo.bar which led me to ask this follow up.

注意:我首先问了一个关于匹配foo.bar的问题,这让我问这个跟进。

1 个解决方案

#1


2  

Full-stop, or indeed any punctuation, is treated like a space in a FULL-TEXT SEARCH, unfortunately this means there is no way to search for punctuation. The reasoning behind this is that text search is for finding "words" (which don't include punctuation).

完全停止,或者实际上任何标点符号都被视为全文搜索中的空格,不幸的是,这意味着无法搜索标点符号。这背后的原因是文本搜索用于查找“单词”(不包括标点符号)。

To do such a search against punctuation, you could match against regular expressions, e.g. by using preg_match.

要对标点符号进行此类搜索,您可以匹配正则表达式,例如通过使用preg_match。

#1


2  

Full-stop, or indeed any punctuation, is treated like a space in a FULL-TEXT SEARCH, unfortunately this means there is no way to search for punctuation. The reasoning behind this is that text search is for finding "words" (which don't include punctuation).

完全停止,或者实际上任何标点符号都被视为全文搜索中的空格,不幸的是,这意味着无法搜索标点符号。这背后的原因是文本搜索用于查找“单词”(不包括标点符号)。

To do such a search against punctuation, you could match against regular expressions, e.g. by using preg_match.

要对标点符号进行此类搜索,您可以匹配正则表达式,例如通过使用preg_match。