SQL Server 2008データベースを使用し、フルテキスト検索を使用するアプリケーションがあります。ハイフンを含むフレーズのSQL Serverフルテキスト検索で期待どおりの結果が返されない
まず、このようなハイフネーションされた単語を含むフレーズ、::
contains(column_name, '"one two-three-four five"')
そして第二に、同じフレーズが、ハイフンはスペースに置き換えられ、私は以下の検索が異なる動作を理由を理解しようとしています:
contains(column_name, '"one two three four five"')
フルテキストインデックスは、ENGLISH(1033)ロケールとデフォルトのシステムストップリストを使用します。
ハイフネーションされた単語を含む他のフルテキスト検索の私の観察から、最初のものはone two three four five
またはone twothreefour five
のいずれかの一致を許可する必要があります。代わりに、one twothreefour five
に一致します(one two-three-four five
ではなく)。
テストケース
セットアップ:
create table ftTest
(
Id int identity(1,1) not null,
Value nvarchar(100) not null,
constraint PK_ftTest primary key (Id)
);
insert ftTest (Value) values ('one two-three-four five');
insert ftTest (Value) values ('one twothreefour five');
create fulltext catalog ftTest_catalog;
create fulltext index on ftTest (Value language 1033)
key index PK_ftTest on ftTest_catalog;
GO
クエリ:
--returns one match
select * from ftTest where contains(Value, '"one two-three-four five"')
--returns two matches
select * from ftTest where contains(Value, '"one two three four five"')
select * from ftTest where contains(Value, 'one and "two-three-four five"')
select * from ftTest where contains(Value, '"one two-three-four" and five')
GO
クリーンアップ:
drop fulltext index on ftTest
drop fulltext catalog ftTest_catalog;
drop table ftTest;
質問は* SQLサーバがマッチングのために異なる挙動を示す理由*詳細については次のとおりです。
は、WHYのリンクに従ってください。それを回避することは確かに可能ですが、 "two-three-four five"は両方の行を返しますが、 "one two-three-four five"は返されません。 「1 2 3 -4」の同上。これは本当に期待される行動ですか?もしそうなら、なぜですか? – Laviak