-
Notifications
You must be signed in to change notification settings - Fork 63
Results from find_by_fuzzy_name often include nil entries #18
Comments
Regarding my second point, I re-read the README and the first paragraph states it find misspelled needles. Oops. So don't worry about that ;) |
No worries. Even though the matches are fuzzy (that's the point), they always should be ordered by best match—did you bump into a counter-example? |
The matches are indeed ordered by best match. But many of the result elements are Secondly, I search fuzzily across multiple model types and combine the results. While each type's matches are ordered by best match within that type, I can't find a way to get at the match score so I can order across all the types' results. Is this possible?
|
It turns out the I'm fuzzy-searching children in a For example: # fuzzily supports this:
Employee.find_by_fuzzy_name 'joe bloggs'
# but we also need this:
@company.employees.find_by_fuzzy_name 'joe bloggs' This can be fixed by changing Fuzzily to chain its trigram search off the searchable record, instead of starting at the trigram end and working back to the searchable record. Would you be interested in a patch along these lines? Regarding ranking results across types: I found a way to do this - see my comment in #16. |
I fixed this here: airblade@dc8138d. It also solves your N+1 problem where every result is mapped in turn to its owner. |
Thanks for this @airblade. I'll work my way through the scoring issue first. |
While I agree that the mapping can cause a cumbersome N+1, your proposed code doesn't work with Rails 2.3 which I still want to support (it's used in production in plenty of places). I'll keep working on this, no promises though ;) |
A problem with your approach (using
(a reasonable query) blows up badly. Not the fault of your code, but a classic with AR: |
I am trying out fuzzily v0.3.0 on a small (~360) set of records, in Rails 3.0.x.
When I search for a string, many of the results in the default set of 10 are
nil
. Is this expected? It makes pagination rather difficult.Also the matches are extremely fuzzy, i.e. results often don't contain all the letters of the search string. For example
aceven
returnsAce Ventura
as expected, but alsoAgentur Nina Klein
– which is not what I want. Am I doing something wrong or does fuzzily not require all the letters in the search string to be present in the results, in the same order?Thanks in advance.
The text was updated successfully, but these errors were encountered: