SQL Server – Extract Tokens from String Using Full-Text Search

full-text-searchsql serversql-server-2008-r2

What is the query to get the tokens in a string from SQL Server 2008 R2?

I need it to highlight results of FREETEXT

Best Answer

You can use DMV sys.dm_fts_index_keywords_by_document to list the words for a given document, eg something like this:

SELECT DISTINCT display_term
FROM sys.dm_fts_index_keywords_by_document( DB_ID(), OBJECT_ID('dbo.Users') ) X

I had a play with this product a few years ago that does hit-highlighting, it was quite nice but I didn't go past the 30-day trial.