FT インデックスを使用して一致を見つけることができますが、その後、フレーズを解析して隣接する単語を見つける必要があります。残念ながら、FTS は試合の順位を教えてくれません。
設定例を次に示します。
declare @find varchar(100) = 'cafe';
declare @phrase varchar(100) = 'I like the cafe at my office';
;with
x(x)
as ( select cast('<w>'+replace(@phrase, ' ', '</w><w>')+'</w>' as xml)
),
words(pos, word)
as ( select dense_rank() over (order by n),
p.n.value('.', 'varchar(100)')
from x
cross
apply x.nodes('/w')p(n)
)
select d.*
from words w
cross
apply ( select *
from words
where pos in (w.pos-1, w.pos+1)
)d(pos, word)
where w.word=@find