Implement fuzzy search #187
Labels
No labels
bug
duplicate
enhancement
help wanted
high priority
invalid
L
low priority
M
medium priority
needs refinement
question
S
UX research
wontfix
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: local-it/mitgliederverwaltung#187
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/162_fuzzy_search"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description of the implemented changes
The changes were:
What has been changed?
Definition of Done
Code Quality
Accessibility
Testing
Additional Notes
Not sure about accessibility with search on typing, so I created that issue: #188
Overall this looks very good 🚀
Filtering for emails does not work and I added some small suggestions.
Further some tests like these could be useful:
blank character handling
special character handling (@, ., -)
unicode character handling (umlauts ö,ä,ü)
very long search strings
@ -109,2 +123,4 @@endendread :search dosome moduledocs would be nice for the public
searchfunction.@ -111,0 +130,4 @@prepare fn query, _ctx ->q = Ash.Query.get_argument(query, :query) || ""fields = Ash.Query.get_argument(query, :fields) || @default_fieldsthe
fieldsargument is never used in thesearchfunction.@ -111,0 +131,4 @@prepare fn query, _ctx ->q = Ash.Query.get_argument(query, :query) || ""fields = Ash.Query.get_argument(query, :fields) || @default_fieldsthreshold = Ash.Query.get_argument(query, :similarity_threshold) || 0.2Maybe some documentation, what this
0.2threshold means or where does it came from?@ -111,0 +137,4 @@q2 = String.trim(q)pat = "%" <> q2 <> "%"# FTS as main filter and fuzzy search just fo first name, last name and streeslittle typo:
fo@ -111,0 +151,4 @@fragment("? % first_name", ^q2) orfragment("? % last_name", ^q2) orfragment("? % street", ^q2) orfragment("word_similarity(?, first_name) > ?", ^q2, ^threshold) ormaybe the duplicate code for
first namelast nameandstreetcould be generated dynamically by the fields argument?I decided to omit fields now...but maybe during refactoring we could think about a dynamic way
@ -111,0 +153,4 @@fragment("? % street", ^q2) orfragment("word_similarity(?, first_name) > ?", ^q2, ^threshold) orfragment("word_similarity(?, last_name) > ?", ^q2, ^threshold) orfragment("word_similarity(?, street) > ?", ^q2, ^threshold) orfilter for email is missing
adding this worked for me:
You're totally right, i forgot the email field. But I would favor for a simple contains ilike on the email field, because I think fuzzy search on the name already is enough? or what do you think?
I added it as ilike and not as fuzzy search. But we can create another issue if we see we need it :)
@ -197,1 +195,3 @@|> filter(expr(fragment("search_vector @@ plainto_tsquery('simple', ?)", ^search_query)))|> Mv.Membership.Member.fuzzy_search(%{query: search_query,fields: [:first_name, :last_name, :street]these fields are passed to
fuzzy_serach->searchfunction but don't have any effect, as thesearchfunction ignores them.@ -0,0 +31,4 @@Mv.Membership.Member|> Mv.Membership.Member.fuzzy_search(%{query: "john",fields: [:first_name, :last_name, :email]In this test the
emailfield is given, but it only tests thefirst_name"John" and thelast_name"Johnson". It would be good to explicitly test theemailfield.