We have an application using SQL Server 2008 database and full-text search. I am trying to understand why the following searches behave differently:
First, a phrase containing a hyphen word, for example:
contains(column_name, '"one two-three-four five"')
And secondly, an identical phrase, where hyphens are replaced by spaces:
contains(column_name, '"one two three four five"')
The full-text index uses the ENGLISH (1033) locale and the default system stop list.
From my observations of other full-text searches containing transferable words, the first should allow matches on one two three four five or one twothreefour five . Instead, it matches only one twothreefour five (and not one two-three-four five ).
Test case
Setup:
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
Inquiries
--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
Cleaning:
drop fulltext index on ftTest drop fulltext catalog ftTest_catalog; drop table ftTest;
Laviak
source share