// 创建表
CREATE TABLE `TEST_FULL_TEXT_SEARCH`
(
`ID` INT NOT NULL AUTO_INCREMENT,
`TEST` VARCHAR(45) NULL,
PRIMARY KEY (`ID`),
FULLTEXT INDEX `FULL_TEXT` (`TEST` ASC)
)
ENGINE = MyISAM;
// 插入一些记录
INSERT INTO `TEST_FULL_TEXT_SEARCH`
SELECT 1, 'vikas kumar gupta' UNION ALL
SELECT 2, 'kratika gupta' UNION ALL
SELECT 3, 'kratika sharma' UNION ALL
SELECT 4, 'kratika vikas kumar gupta' UNION ALL
SELECT 5, 'kratika shukla' UNION ALL
SELECT 6, 'chetan kastwar' UNION ALL
SELECT 7, 'kratika kastwar' ;
// 现在进入选择查询
SELECT * FROM TEST_FULL_TEXT_SEARCH
WHERE MATCH(test)
AGAINST('kratika' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION );
// 或者
SELECT * FROM TEST_FULL_TEXT_SEARCH
WHERE MATCH(test)
AGAINST('kratika' WITH QUERY EXPANSION);
// 输出
1 vikas kumar gupta
4 kratika vikas kumar gupta
3 kratika sharma
5 kratika shukla
2 kratika gupta
- 为什么它没有在结果集中选择“ kratika kastwar ”?
- 为什么要先写“vikas kumar gupta”
// 现在我们在布尔模式下搜索
SELECT * FROM TEST_FULL_TEXT_SEARCH
WHERE MATCH(test)
AGAINST('kratika' IN BOOLEAN MODE);
// 输出
2 kratika gupta
3 kratika sharma
4 kratika vikas kumar gupta
5 kratika shukla
7 kratika kastwar
- 为什么有' kratika kastwar '?
// 现在我们在布尔模式下搜索而不进行查询扩展
SELECT * FROM TEST_FULL_TEXT_SEARCH
WHERE MATCH(test)
AGAINST('kratika' IN NATURAL LANGUAGE MODE);
// 输出
No result found
请说明为什么它没有在列表中选择“ kratika kastwar ”
// 已编辑
为什么它显示“ vikas kumar gupta ”IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION
或WITH QUERY EXPANSION
排名第一而不是与kratika相关的结果?