0

Is there a way to search for text within a string and return how much of a percentage match was found?

For example, if I search for "City Hospital Aberdeen" in the following strings;

"City Hospital" "City Hospital Aberdeen County" "City Hospital Surrey"

I would like to be able to know how much of a match each search to determine which string best matched what was being searched for.

Normally I would perform this type of search on the database itself using indexes, but the database I'm working with belongs to another application and I want to avoid making any changes to it.

My first thought was to break the strings up into each word, and find out how many of the words exist in the string, but this won't be accurate enough I don't think.

SheppardDigital
  • 3,165
  • 8
  • 44
  • 74
  • 1
    that is the most accurate match you can get (at least with not way too much effort). but it might take pretty long, depending on the search string as well as the string you are searching in – XtremeBaumer Jan 30 '18 at 14:24
  • 1
    Sounds like you are on your way to developing a search engine. Use elastic instead. – Tobb Jan 30 '18 at 14:25
  • Thanks @Hovercraft Full of Eels the answer in that question works perfect for my application – SheppardDigital Jan 30 '18 at 14:39

0 Answers0