New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add duty station search improvements: 167501188 #2760
Add duty station search improvements: 167501188 #2760
Conversation
c6302cb
to
143a816
Compare
Codecov Report
@@ Coverage Diff @@
## master #2760 +/- ##
========================================
+ Coverage 57.6% 57.6% +0.1%
========================================
Files 278 276 -2
Lines 12567 12550 -17
========================================
- Hits 7233 7226 -7
+ Misses 4586 4578 -8
+ Partials 748 746 -2 |
There's another pivotal story that deals with the fact we're doing an |
@@ -0,0 +1,3 @@ | |||
CREATE EXTENSION pg_trgm; | |||
|
|||
CREATE INDEX duty_stations_name_trgm_idx ON duty_stations USING gin(name gin_trgm_ops); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Can we test this on experimental with the load testing framework? I can show you how.
with names as ( | ||
(select id as duty_station_id, name, similarity(name, $1) as sim | ||
from duty_stations | ||
where similarity(name, $1) > 0.03 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to get away with using the % operator with these similarity calls, if we set the pg_trgm.similarity_threshold to the 0.03 value we're using (default is 0.3, so definitely would need to override in that case). Since the operator returns a true/false based on the threshold as opposed to the value, I suspect it might run a bit faster (I wouldn't hold the PR up over this, just something to think about).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't use % in case we want to tweek the similarity threashold and figured it clearer what was happening if things were in the query... and setting the threashold didn't add much/any speed gains since we're not dealing w/ a ton of rows.
However, if/when we add additional duty stations
- we should def. keep this in mind for query optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great! I left a minor comment about the query, but otherwise this seems to do what it's supposed to. I think after the load testing that was mentioned in another comment it's good to go. 🚀
@chrisgilmerproj results from load testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 - Awesome work. Thanks for doing the load testing check on this endpoint because its caused us so much trouble in the past.
Also, don't forget to undo the changes to experimental :)
@chrisgilmerproj do you mean pushing to experimental again to reset the |
Yep! You'll want to turn off that variable. And then remove the stuff from this PR. |
a2ac006
to
cde02be
Compare
Description
Make searching for a duty station more flexible... allow "fuzzy" matching.
Use trigram matching when letting a SM or an Office user search for duty stations. Calculate the similarity between the "search query" and the duty stations and return the top 7 results.
Reviewer Notes
Alternate spellings/abbrs we want to catch are in the pivotal story linked as a spreadsheet.
Setup
Add any steps or code to run in this section to help others prepare to run your code:
make server_test
make server_run
make client_run
Log into SM or Office app and do a duty station search using "alternate" duty station names... or try fuzzy searching for things:
ft bragg
=>fort bragg
joint base
=> recs forJB *
Code Review Verification Steps
Querying the Database Safely
have been satisfied.
References
Screenshots