[英]Sql Server 2008 “Contains” search searching for numeric value returns all records with a different number of the same length?
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. 听起来令人难以置信,事实证明,如果将全文索引“断词器语言”设置为除“英语”以外的任何其他内容,则全文索引将仅索引数字字符串的前5个数字。 This means that the above is returning as a match because they both start "10010".
这意味着上面的内容将作为匹配项返回,因为它们都以“ 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"')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.