Sergey Tarasov
Sergey Tarasov

Reputation: 888

How can I know when SQL Server Full Text Search has indexed a record?

My question is similar to this one: How can I know when SQL Full Text Index Population is finished? only instead of population status of the whole index I need to know if SQL Server Full Text Search (FTS) has already indexed certain record in the table.

In other words, given a key from the table is there a way to check if that row has already been picked up by FTS daemon, analyzed and included into corresponding FTS index?

The question is because I'd like to piggyback FTS and use CONTAINS to check if newly added row matches certain conditions.

Upvotes: 3

Views: 2390

Answers (1)

Keith
Keith

Reputation: 21264

Use sp_fulltext_keymappings. If a record exists in this result set where key = [primary key value from your table] then the table record is indexed.

To get a list of all records that are indexed:

declare @objectId int = OBJECT_ID('dbo.Table1')
exec sp_fulltext_keymappings @objectId

To determine if a single record is indexed, pass the primary key value as the 3rd parameter in the query below. If the result set is empty then the record is not indexed.

declare @objectId int = OBJECT_ID('dbo.Table1')
exec sp_fulltext_keymappings @objectId, null, 1

Upvotes: 4

Related Questions