简体   繁体   English

SQL Server 2008“包含”搜索搜索数值是否返回具有相同长度的不同编号的所有记录?

[英]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.

相关问题 限制查询数在SQL Server 2008中返回 - Limiting the number of queries returns in SQL Server 2008 使用SQL Server 2008全文本搜索来查找地址匹配项 - searching for address matches using sql server 2008 full text search SQL Server-计算所有列中具有相同值的记录 - SQL Server - Counting records with same value across all columns 如何使用来自同一表中具有不同ID值的记录来更新SQL-Server 2008表 - How to update a SQL-Server 2008 table with records from the same table with different ID values 如何查找组 SQL Server 中所有记录的值是否相同 - How to find if a value is same for all the records in a group SQL server SQL Server 2008 case语句对记录进行计数,而不对具有相同日期但结果不同的另一条记录进行计数 - SQL Server 2008 case statement to count records and not another record with same date but different result 计数同一表上具有不同值的记录可能没有SQL Server 2008 - counting records on the same table with different values possibly none sql server 2008 在sql server中搜索数字或字符串值作为通配符 - Search numeric or string value as wildcard in sql server 在SQL Server 2008中四舍五入到最接近的所有数字 - Rounding to the nearest all number in sql server 2008 在SQL Server 2008表中搜索uniqueidentifier值 - Search uniqueidentifier value in SQL Server 2008 table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM