mysql布尔模式选择查询

时间:2016-10-25 22:13:41

标签: mysql full-text-search

当我对表中的记录运行以下查询时:

SELECT TRIM(city_table.City_Name)
   as label,city_table.Area_Name, city_table.Area_Code, city_table.City_Code as `City`,
   city_table.Country_Code ,city_table.Country_Name as CountryName,
   city_table.City_Code as `value`
FROM `city_table`
where MATCH(city_table.SearchString) AGAINST('+al* +ain*' IN BOOLEAN MODE )

没有返回任何数据。我可以看到我有“al ain”,但是当我运行相同的查询时:

SELECT TRIM(city_table.City_Name)
   as label,city_table.Area_Name, city_table.Area_Code, city_table.City_Code as `City`,
   city_table.Country_Code ,city_table.Country_Name as CountryName, city_table.City_Code as `value`
FROM `city_table`
where MATCH(city_table.SearchString)
AGAINST('+dub*' IN BOOLEAN MODE ) 

记录正确返回。

同样,不会返回记录:

SELECT TRIM(city_table.City_Name)
   as label,city_table.Area_Name, city_table.Area_Code, city_table.City_Code as `City`,city_table.Country_Code ,
   city_table.Country_Name as CountryName, city_table.City_Code as `value`
FROM `city_table` where MATCH(city_table.SearchString)
AGAINST('+umm*' IN BOOLEAN MODE ) 

但是使用不同字符串的相同查询(如“Gha”或“Ajm”)将返回记录。

该表包含'umm'和'al'的记录,但仍未显示。我无法附上要显示的记录图像,但我在表格中有以下字段。

City_Name City_CodeArea_NameArea_CodeCountry_Code SearchString Country_Name。

1 个答案:

答案 0 :(得分:0)

我没有看到任何明显不正确的错误,但是,您应该知道,默认情况下,FULLTEXT索引中要索引的单词长度的最小值是四个字符。有时它会起作用,有时则不行!见Potentially relevant info here.