SQL Server Full Text Search Leading Wildcard

≯℡__Kan透↙ 提交于 2019-12-18 06:55:06

问题


After taking a look at this SO question and doing my own research, it appears that you cannot have a leading wildcard while using full text search.

So in the most simple example, if I have a Table with 1 column like below:

TABLE1

coin
coinage
undercoin

select COLUMN1 from TABLE1 where COLUMN1 LIKE '%coin%' Would get me the results I want.

How can I get the exact same results with FULL TEXT SEARCH enabled on the column?

The following two queries return the exact same data, which is not exactly what I want.

SELECT COLUMN1 FROM TABLE1 WHERE CONTAINS(COLUMN1, '"coin*"')

SELECT COLUMN1 FROM TABLE1 WHERE CONTAINS(COLUMN1, '"*coin*"')

回答1:


Full text search works on finding words or stems of words. Thus, it does not find the word "coin" anywhere in "undercoin". What you seek is the ability search suffixes using full text searches and it does not do this natively. There are some hacky workarounds like creating a reverse index and searching on "nioc".



来源:https://stackoverflow.com/questions/2664387/sql-server-full-text-search-leading-wildcard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!