I have a search where users can enter any value, sometimes these are legitimately just numeric. When searching for
Select * FROM Updates WHERE contains(Remarks, '"10010234331"')
it will return unrelated results that have numbers in of the same length, ie one match for the above is
"PO input differently on orders, refs are:
1001024894
10010248940"
As you can see, the search is not a substring of either of these. Any ideas how to tell it to not just guess?
Right.
As unbelievable as this sounds, it turns out that if the full-text index "language for word-breaker" is set to anything other than "English", the full-text index will only index the first 5 numbers of a number string. This means that the above is returning as a match because they both start "10010".
"French, "German", "Hebrew", even "Neutral" was returning incorrect results, only "English" returns only matches for the whole string.
create table wtFTI( taskid int not null , remarks text, constraint [PK__wtFTI] primary key(taskid))
insert into wtfti
values(3513792, 'Remarks: 1001019658 was cancelled 26/08')
GO
CREATE FULLTEXT CATALOG [TaskRemarks]WITH ACCENT_SENSITIVITY = OFF
GO
CREATE FULLTEXT INDEX ON [dbo].[wtFTI] KEY INDEX [PK__wtFTI] ON ([TaskRemarks]) WITH (CHANGE_TRACKING = AUTO, STOPLIST = SYSTEM)
GO
ALTER FULLTEXT INDEX ON [dbo].[wtFTI] ADD ([remarks]LANGUAGE 'French')
GO
ALTER FULLTEXT INDEX ON [dbo].[wtFTI] ENABLE
GO
Select * FROM [wtFTI] WHERE contains(Remarks, '"1001019000"')
ALTER FULLTEXT INDEX ON [dbo].[wtFTI] DROP ([remarks])
GO
ALTER FULLTEXT INDEX ON [dbo].[wtFTI] ADD ([remarks] LANGUAGE 'English')
GO
Select * FROM [wtFTI] WHERE contains(Remarks, '"1001019000"')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.