I have a couple of million records in a Microsoft SQL Server database table. The search with [Column] LIKE '%test%'
is way too slow. Therefore, I use a full text search.
My query looks as follows after a lot of tries with CONTAINS
and FREETEXT
...
SELECT [SearchText] FROM [Service].[CatalogArticleCache] AS t
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*426*"') AS s1 ON t.ArticleId = s1.[KEY]
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*211*"') AS s2 ON t.ArticleId = s2.[KEY]
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*Geschweisst*"') AS s3 ON t.ArticleId = s3.[KEY]
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*rohr*"') AS s4 ON t.ArticleId = s4.[KEY]
--INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*bogen*"') AS s5 ON t.ArticleId = s5.[KEY]
ORDER BY [SearchText]
That query returns a couple of records such as...
426 211357 .Geschweisste Rohrbogen 2d90
426 211682 .Geschweisste Leitungsrohre ungegl.
426 211990 .Geschweisste Rohrbogen D + 100
...
As soon as I include the second last line of my SQL query, I expect the result in the middle would be gone. Unfortunately, the query returns not a single row.
Why that and how to fix it?