-
Notifications
You must be signed in to change notification settings - Fork 189
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
Implement Author Autocomplete (legacy backend and Search) #3301
Conversation
1401467
to
dac33df
Compare
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 is amazing! I've done one read through, and will spend more time on it tomorrow, but it looks fantastic.
We should figure out if we can migrate this to the parser service, since it's landing soon (can happen in follow-up).
dac33df
to
d8867e9
Compare
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.
Google should consider hiring us.
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 had to spend some time learning on Edge n gram which was very interesting.
I tried to test this PR, the server ran but I couldn't to get any result back.
* http://localhost/v1/search/complete/?author=Da
returns 404
* http://localhost/v1/search/authors/autocomplete/?author=Da
returns 404
Edit: my backend took a while to index for some reason
Also the query looks strange, should it be http://localhost/v1/search/autocomplete?author=Da
The URL changed to |
I think it would be better to have |
Yeah agree, the endpoint should look like |
@TueeNguyen , That interesting how the routing works, |
I think whatever is after the |
d8867e9
to
00138d0
Compare
Added comments |
00138d0
to
5ebc4bf
Compare
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.
Let's do it.
*/ | ||
const validateQuery = () => { | ||
return async (req, res, next) => { | ||
await Promise.all(ValidationRules.map((rule) => rule.run(req))); | ||
const rules = req.route.path === '/' ? ValidationRules : authorRules; |
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 makes me nervous, but let's go with it for now and fix later. I'd rather split these routes up vs. having this logic determine what we do.
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.
LGTM, tested locally it works. Great feature @rclee91
- Add author autocomplete settings for indexer.js in backend - refactor Search service to work wwith new indexing - create /authors/autocomplete search query for author autocomplete - add search term highlights - add comments - create new validation rules for author autocomplete
5ebc4bf
to
3c7bd21
Compare
Issue This PR Addresses
Fixes #1417
also a part of issue #3225 (no new tests are added just yet)
Type of Change
Description
backend
, I've addedsettings
andmapping
for theposts
index to use edge n-gram for author autocompletetype
on index creation, I've refactored theSearch
service and tests to work with the new indexing. The current search query is not affected by this new change.pnpm test search
would pass all tests.Search
, and ways to test it and see it in action is as followsSteps to test the PR
pnpm install
redis
cacherm -rf redis-data
, this is so the posts can be re-indexedpnpm start
Search
queries at http://localhost/v1/searchauthor
is queried, it will return the number of suggested authors, and an array of suggested authors. As the query gets longer, results will be more preciseProblems
There is still a lot of tweaking that can be done
author
query and it passes validation, we'll get aError 400
validation.js
Checklist