简体   繁体   中英

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

I want to know if the possible to do with the use of contains and freetext . 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. But this are just ideas can someone help me.

UPDATE

I tried with the function soundex but it doesn't help me to much...

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. 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...). 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('_', ' ');

试试Soundex

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.

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