如何在全文搜索中实现数值搜索?
how achive numeric value search in full text search?
喜欢的条件:
product.product_name like '%7 up%'
输出here
全文搜索:
MATCH(product.product_name) AGAINST('+7+up' IN BOOLEAN MODE)
或
MATCH(product.product_name) AGAINST('"7 up"' IN BOOLEAN MODE)
为什么上面的两个查询都没有返回任何结果?
第一个表达式看起来不错,但是您应该知道,默认情况下,MySQL 会忽略短于三个字符的单词。这由参数 innodb_ft_min_token_size. It is possible to change that parameter but it requires to restart the server and rebuild your FULLTEXT indexes ; this is not recommended by mysql. See this document 控制以获取有关全文调整的更多详细信息。
第二个表达式,包含双引号,将尝试执行 乱码匹配:这似乎不是您需要的。
简而言之:考虑到您要搜索的内容,您最好使用 LIKE
。
喜欢的条件:
product.product_name like '%7 up%'
输出here
全文搜索:
MATCH(product.product_name) AGAINST('+7+up' IN BOOLEAN MODE)
或
MATCH(product.product_name) AGAINST('"7 up"' IN BOOLEAN MODE)
为什么上面的两个查询都没有返回任何结果?
第一个表达式看起来不错,但是您应该知道,默认情况下,MySQL 会忽略短于三个字符的单词。这由参数 innodb_ft_min_token_size. It is possible to change that parameter but it requires to restart the server and rebuild your FULLTEXT indexes ; this is not recommended by mysql. See this document 控制以获取有关全文调整的更多详细信息。
第二个表达式,包含双引号,将尝试执行 乱码匹配:这似乎不是您需要的。
简而言之:考虑到您要搜索的内容,您最好使用 LIKE
。