I am having trouble showing records that contain the word "under" using the SQL CONTAINS function. I read the Microsoft documentation for this and based on example there using the AdventureWorks DB, result set is as expected but having a hard time when the same example is applied to search for records having the word "under".
Here is my script I working on that you can also execute to simulate the scenario:
--Creating table
CREATE TABLE MyTable
(
ID INT NOT NULL IDENTITY(1,1),
[Description] NVARCHAR(200) NULL
CONSTRAINT PK_ID PRIMARY KEY CLUSTERED (ID)
)
--Populating table
INSERT INTO MyTable
SELECT 'Testing'
UNION SELECT 'This is it'
UNION SELECT 'Under the name of whoever'
UNION SELECT 'I undergo surgery'
UNION SELECT 'Under Armour'
UNION SELECT 'Frequent under the table'
UNION SELECT 'I am underpaid too'
UNION SELECT 'Anything under the sun'
UNION SELECT 'What is the matter peanut butter'
UNION SELECT 'Underline'
UNION SELECT 'Chainring Bolts'
UNION SELECT 'Chaining Nut'
UNION SELECT 'Chainring'
UNION SELECT 'Chain Stays'
UNION SELECT 'Chain'
UNION SELECT 'Dummy Chain'
UNION SELECT 'Land Down Under'
UNION SELECT 'Many Underlings'
UNION SELECT 'Only Undo'
--One time setup to enable fulltext search
EXEC sp_fulltext_database 'enable'
GO
CREATE FULLTEXT CATALOG FTCSearch
GO
CREATE FULLTEXT INDEX ON MyTable([Description])
KEY INDEX PK_ID ON FTCSearch
GO
Query:
--Query showing phrases that have c prefix
SELECT * FROM MyTable
WHERE CONTAINS([Description], ' "c*" ')
--Getting the expected result
--Query showing phrases that have u prefix
SELECT * FROM MyTable
WHERE CONTAINS([Description], ' "under*" ')
--Not getting expected result: Missing phrases that contains 'under' word
--Missing: Under the name of whoever
--Missing: Under Armour
--Missing: Frequent under the table
--Missing: Anything under the sun
--Missing: Land Down Under
--Missing: Under the name of whoever


