0

I am using MongoDB via .Net.And I would like to make a autocomplete api. But I do not know how to match in one case. Let me explain it by giving example;

 I wrote -- Results
    "Ema" => "Email" , ""...
    "Emasil" => "Email", ""...
    "Emasil Li" => "Email List", ""...
    "Emasil Lit" => "Email List", ""...
    "Emasil Litk" => "Email List", ""...

as shown the above, even if I wrote it mistake, it gave me the results.This is what exactly I need.But I don't have any idea how to do this. Can you please show me a way to solve this problem?

seyid yagmur
  • 1,572
  • 17
  • 26

2 Answers2

0

I don't think MongoDB can help you with that entirely (could be wrong). Seems like you want to create a spelling corrector / predictive text type solution? There are prebuilt libraries that can do that for you, like this one used by google written in Python: http://norvig.com/spell-correct.html. I guess you could store the dictionary or collection of potential text matches in mongodb and somehow incorporate that in your solution, but I'm not aware of a means of querying the fields of a collection in a spell check type manner.

robjwilkins
  • 5,462
  • 5
  • 43
  • 59
0

Answers the question Implement autocomplete on MongoDB may be able to help you.

In general your problem is related to fuzzy string search. The basic algorithm used the Levenshtein distance for determining how strings are similar each other. But there are another algorithms such as bitap algorithm, Needleman–Wunsch algorithm, Spell-checker method, N-gram method and others. You may find more details for example in the article Fuzzy string search, or Fuzzy search algorithm (approximate string matching algorithm). Also check the search libraries such as Apache Lucene.Net (see Apache Lucene for more details), fuzzystring.

Didgeridoo
  • 1,222
  • 2
  • 14
  • 21