
Full-stack engineering · Technical leadership
20 years of engineering. Built through delivery.
From user interfaces and APIs to SQL Server, financial-crime technology and production problem-solving.
Explore my experience
SQL Server and search
Understand full-text catalogues, indexes, ranked queries and the checks needed for application search.
SQL Server Full-Text Search helps an application find words and phrases in indexed text. A full-text catalogue is a logical container for full-text indexes; it is not a product catalogue or an application entity table.
Decide whether users need word matching, phrases or ranked results. Full-text search follows language and tokenisation rules. It behaves differently from a substring pattern such as LIKE '%term%'. Test the terms your users actually enter before selecting an approach.
The SQL Server instance needs the Full-Text Search component. Create a catalogue and a full-text index for the required text columns. The index needs a unique, single-column, non-nullable key. Choose language settings deliberately; the example uses English, not a universal language configuration.
This sample creates a development-only table and index. It demonstrates structure and query syntax, rather than reproducing a client implementation.
-- Educational example: use a separate development database.
CREATE TABLE dbo.KnowledgeArticle
(
ArticleId int NOT NULL
CONSTRAINT PK_KnowledgeArticle PRIMARY KEY,
Title nvarchar(200) NOT NULL,
Body nvarchar(max) NOT NULL
);
GO
CREATE FULLTEXT CATALOG KnowledgeSearch;
GO
CREATE FULLTEXT INDEX ON dbo.KnowledgeArticle
(
Title LANGUAGE 1033,
Body LANGUAGE 1033
)
KEY INDEX PK_KnowledgeArticle
ON KnowledgeSearch
WITH CHANGE_TRACKING AUTO;
GO
-- Populate the table, then allow indexing to complete.
DECLARE @Terms nvarchar(4000) = N'"risk" AND "screening"';
SELECT a.ArticleId, a.Title, matches.[RANK]
FROM CONTAINSTABLE(dbo.KnowledgeArticle, *, @Terms) AS matches
JOIN dbo.KnowledgeArticle AS a
ON a.ArticleId = matches.[KEY]
ORDER BY matches.[RANK] DESC, a.ArticleId;CONTAINS filters rows using a full-text condition. CONTAINSTABLE also returns the key and a relative rank for each match, which can be joined to the original table. FREETEXT and FREETEXTTABLE offer linguistic matching for less structured search input. A rank is not a business-risk score or a confidence probability.
Automatic change tracking updates the full-text index in the background. Newly saved text may not appear in search immediately. Check population status and pending changes when records appear to be missing; do not assume that a successful insert means indexing is finished.
Use parameterised database calls. Validate full-text search syntax and handle invalid or empty input. Apply the application's authorisation filters before returning records. Test language behaviour, phrases, prefixes, punctuation and stopwords with representative content. Compare relevance and execution time on realistic data rather than promising a fixed speed-up.
Inspect sys.fulltext_indexes and sys.dm_fts_index_population to understand configuration and active population. Monitor index health alongside ordinary database workload. Record the tested search examples and expected matches so changes can be reviewed consistently.