全文索引的contains的疑问
如下的sql语句,为什么结果不一致呢?
1 select count(id) from tablename where name like '%爱%'
2 select count(id) from tablename where contains(name,'爱')
3 select count(id) from tablename where contains(name,'"爱"')
4 select count(id) from tablename where contains(name,'"爱*"')
语句1的结果是最准确的,4的结果小与语句1,2和3的结果一致
语句2 select count(id) from tablename where contains(name,'爱'),是搜索在name列中包含"爱"这个词的所有记录
语句3 select count(id) from tablename where contains(name,'"爱"'),是搜索在name列中包含"爱"这个短语的所有记录
问题一:
其实2和3是一致的,因为关键词就是一个字,但是如果换成一个短语,例如"爱恨交加",按照我的理解语句2和3应该也是一样的,难道语句2会对短语进行分词么?
问题二:
语句4 select count(id) from tablename where contains(name,'"爱*"'),是搜索在name列中以"爱"开头的所有记录,书上说通配符不能放在词的开始处,因为索引是从字符的开头开始搜索,但是
select count(id) from tablename where contains(name,'"*爱"')和select count(id) from tablename where contains(name,'爱')的结果是一样的,而且select count(id) from tablename where contains(name,'"*爱*"')和select count(id) from tablename where contains(name,'"爱*"')结果也是一样的
问题三:
like和contains的结果不相符,like是数据库来进行处理,contains是Microsoft的搜索服务来处理,难道是这个原因而导致的而这结果不一致么?
期待各位高手的精彩解答!!