简体   繁体   English

我该如何实现这个搜索

[英]how can i implement this search

i'm trying to develop a search that allow me to accomplish this 我正在尝试开发一种允许我完成此操作的搜索

String to search 要搜索的字符串

This is a text

the user input 用户输入

this_is_a_text
this a text
tihs a txt <----notes that the user made a wrong input

but always gave me the best coincidence that would by this is a text 但总是给我最好的巧合,这将this is a text

I want to know if the possible to do with the use of contains and freetext . 我想知道是否可以使用containsfreetext I'm also i been thinking to do it matching character by character in a method in c# loading all the records because there only 300 hundred and makeing a percentage of equals. 我也一直在考虑在c#中加载所有记录的方法中逐个字符地匹配,因为只有300个并且构成等于的百分比。 But this are just ideas can someone help me. 但这只是想法可以有人帮助我。

UPDATE UPDATE

I tried with the function soundex but it doesn't help me to much... 我尝试使用函数soundex,但它对我帮助不大...

If you are wanting to do a one off reconciliation of data you are probably best loading both lists to match into C# and then use an edit distance algorithm such as Levenshtein Distance to iterate through best matches. 如果您想要对数据进行一次性协调,则最好加载两个列表以匹配到C#,然后使用编辑距离算法(如Levenshtein Distance)来迭代最佳匹配。 Can be very time consuming but like I say - if you only have to do once... 可能非常耗时,但就像我说的 - 如果你只需做一次......

You could implement this algorithm as a function in SQLServer (a Googling will find you plenty of people who have already done this for you...). 您可以将此算法实现为SQLServer中的一个函数(谷歌搜索会找到很多已经为您完成此操作的人...)。 Also, algorithms such as these can give unwanted or unexpected matches where a human matcher would have picked another alternative. 此外,诸如此类的算法可以提供不需要的或意外的匹配,其中人类匹配器将选择另一种替代方案。

Be careful! 小心!

You could use a replace method. 您可以使用替换方法。

var stringToSearch = userInputText.Replace('_', ' '); var stringToSearch = userInputText.Replace('_','');

试试Soundex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM