简体   繁体   English

如果多行匹配,MySQL FullText搜索返回0

[英]MySQL FullText search returns 0 if multiple row matches

Match / Against returns true if I pass unique value in query and returns 0 if I pass value, which exist in multiple row. 如果我在查询中传递唯一值,则Match / Against返回true;如果我传递值(存在于多行中),则Match返回值为0。

SELECT MATCH(b.branch_name) 
AGAINST ('Men' IN NATURAL LANGUAGE MODE ), branch_name 
FROM `branch` AS `b` WHERE 1

Table Data:
id   | branch_name
--------------------
1    | Men 
2    | Beauty
3    | Women

If I pass MATCH(b.branch_name) AGAINST ('Men' IN NATURAL LANGUAGE MODE ) returns 0 for all row, If I pass MATCH(b.branch_name) AGAINST ('Women' IN NATURAL LANGUAGE MODE ) returns > 0 value same for 'beauty' 如果我通过MATCH(b.branch_name) AGAINST ('Men' IN NATURAL LANGUAGE MODE )为所有行返回0,如果我通过MATCH(b.branch_name) AGAINST ('Women' IN NATURAL LANGUAGE MODE ) MATCH(b.branch_name) AGAINST ('Men' IN NATURAL LANGUAGE MODE )返回的所有值都MATCH(b.branch_name) AGAINST ('Women' IN NATURAL LANGUAGE MODE ) 0 'beauty'

Can anyone please help me where am I wrong? 谁能帮我哪里错了?

There is a system variable called ft_min_word_len whose default value is 4 (see here ). 有一个名为ft_min_word_len的系统变量,其默认值为4(请参见此处 )。

That means that words of less than four letters are ignored -- not included in the index. 这意味着少于四个字母的单词将被忽略-不包括在索引中。 No entry in the index; 索引中没有条目; no rows returned. 没有返回任何行。

Reset the value and then rebuild the index so "men" will be in the index. 重置该值,然后重建索引,以使“ men”位于索引中。 Then your query will work. 然后您的查询将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM