问题
I have SQL script as below for querying my ContactInfoes
table
SELECT *
FROM ContactInfoes
WHERE CONTAINS(Name, 'The')
I am getting only empty result set. I have an entry in my table with Name 'The Company'.
Why I am not getting any data here and how this can be resolved. Any help is appreciated.
I am using SQL Server 2019
回答1:
You have created FULLTEXT index without specifying STOPLIST. Thus, the default STOPLIST was used. By default the word 'the' is the stop word, that removed from your text. If you want to search by word 'the' you should create an empty STOPLIST and then specify this STOPLIST in your FULLTEXT INDEX. The default stop words you can check by query:
SELECT *
FROM sys.fulltext_system_stopwords
WHERE language_id = 1033 -- English
Then you can create empty STOPLIST:
CREATE FULLTEXT STOPLIST MyEmptyStopList;
GO
Then set it into your FULLTEXT INDEX:
CREATE FULLTEXT INDEX ON table_name ... STOPLIST = MyEmptyStopList;
回答2:
The simple solution for me was to turn off the stop list using below script
ALTER FULLTEXT INDEX ON [tablename] Set StopList = OFF
I already have an index configured, which was using the default stoplist. I am turning off the stoplist here
来源:https://stackoverflow.com/questions/62061744/sql-contains-not-returning-results-for-the