Single-threaded text search in Microsoft SQL works with 25 out of 26 letters - but not "n" - returns all rows

Found an interesting problem with fast search, if you are doing a single character search, 25 characters work fine, one doesnt - "n" Fast search is selected like this:

SELECT* FROM some_full_text_table WHERE CONTAINS(the_full_text_field, ' "n*" ')

      

It should look for the full text field in the table for anything starting with "n".

Examples of data lines:

  • "name1 foo bar us cardiac"
  • "aname foo2 us echo"
  • "some name foo3 ct"
  • "requested letter

The query should return lines 1 and 3, as they are the only ones that have words starting with "n".

The actual result is all rows are returned, even row 4, which has no ns at all.

I really believe this is a SQL bug. "na *" works as expected and returns 1 and 3.

Look for a solution or work around

Here is a SQL 2014 example

create table TestFullTextSearch (
    Id int not null,
    AllText nvarchar(400)
)

create unique index test_tfts on TestFullTextSearch(Id);
create fulltext catalog ftcat_tfts;
create fulltext index on TestFullTextSearch(AllText)
    key index test_tfts on ftcat_tfts
    with change_tracking auto, stoplist off
go

/* No n in the data */

insert into TestFullTextSearch values (1, 'legacyreport Report Legacy 23049823490  20150713 Cardiac US ')
insert into TestFullTextSearch values (2, '123-45-678 foo bar  19450712 20020723 Exercise Stress US ')
insert into TestFullTextSearch values (3, '2048 jj goodguy xy2000 19490328 20150721 Cardiac US ')
insert into TestFullTextSearch values (4, '12345678 4.0 ALLCALCS  19650409 20031103 Cardiac Difficult US ')

select * from TestFullTextSearch where contains(AllText, '"n*"')

/* the result of the select */
1   legacyreport Report Legacy 23049823490  20150713 Cardiac US 
2   123-45-678 foo bar  19450712 20020723 Exercise Stress US 
3   2048 jj goodguy xy2000 19490328 20150721 Cardiac US 
4   12345678 4.0 ALLCALCS  19650409 20031103 Cardiac Difficult US 

      

+3


source to share





All Articles