Implement full-text search for members closes #11 #163
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 milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: local-it/mitgliederverwaltung#163
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/11-fulltext-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:
Implement full-text search
What has been changed?
Definition of Done
Code Quality
Accessibility
Testing
Additional Notes
Futty / Substring search not part fo this PR
Great work! I think there are two things we should address before merging, but overall this is really well done.
@ -19,0 +28,4 @@def handle_info({:search_changed, q}, socket) domembers =Mv.Membership.Member|> Ash.Query.filter(expr(fragment("search_vector @@ plainto_tsquery('simple', ?)", ^q)))It seems like this returns an empty list when the search string is empty. Maybe we need a special case for that, so an empty search field shows all members instead?
@ -19,0 +31,4 @@|> Ash.Query.filter(expr(fragment("search_vector @@ plainto_tsquery('simple', ?)", ^q)))|> Ash.read!()IO.inspect(members)Let's remove this before merging.
@ -0,0 +44,4 @@CREATE TRIGGER update_search_vectorBEFORE INSERT OR UPDATE ON membersFOR EACH ROWEXECUTE FUNCTION members_search_vector_trigger()This constructs the search vector for all new future members, but can we run it in this migration for all existing members as well?
But is this a use case?
I would rather put that in an own low priority issue due to priorisation if that's fine?
Yeah, I think if we all just reset our database we should be fine as well. No need to create an issue. I was just confused that I could not find all members in my database :D
I think we also should check for substrings of names.
e.g. I just tried to search for Friedrich, typed "Fried" and wondered, why I got no results
@simon wrote in #163 (comment):
This is intentional as the current implementation only uses full-text search which only matches whole words, and is optimized to search large volumes of text. I think the idea was to open an issue and a follow-up MR implementing fuzzy and substring search.
ah yes, I see! ty
@ -0,0 +8,4 @@use MvWeb, :live_component@impl truedef update(assigns, socket) do@ -0,0 +20,4 @@|> element("form[role=search]")|> render_change(%{"query" => "Friedrich"})assert html =~ "Friedrich"Doesn't this just assert that "Friedrich" should occur anywhere in the html?
If I'm not wrong, this would also apply to the exact same search string "Friedrich" which is rendered in html, too, and therefore it doesn't matter for the test which result is presented?
Yes, you are right :) Changed that to checking if members are not present instead
@ -76,0 +80,4 @@send(view.pid, {:search_changed, "Friedrich"})# State aus dem LiveView-Prozess holena bit picky, but this comment should be in english :)