seamusabshere / fuzzy_match

Find a needle (a document or record) in a haystack using string similarity and (optionally) regular expression rules. Uses Dice's Coefficient (aka Pair Similiarity) and Levenshtein Distance internally.
MIT License
677 stars 46 forks source link

Best way to search over multiple active record models? #16

Closed airblade closed 9 years ago

airblade commented 10 years ago

I have a search box in my webapp which fuzzy-searches over several different ActiveRecord models (e.g. Company, Person).

How would you recommend providing the top 10 results from across all sources?

seamusabshere commented 10 years ago

hi @airblade apologies for my terribly late reply - you might try

  1. get top 50 results for each model via postgres trigram matching
  2. put all of those records into a FuzzyMatch and get the top 10