-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: Auto update algolia index #488
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
index | ||
.saveObjects(coursesForIndex) | ||
.then(({ objectIDs }) => { | ||
console.log(objectIDs); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); |
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.
Are you going to update a single index by clearing it and then adding new data or doing this? iirc if you say run this twice in succession you'll have duplicate records in the index. I think the objectID
should make it so it doesn't but just want to check in.
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.
What is the plan for stale courses? ie. courses that don't exist anymore cause this will make it so some will linger.
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.
yep you're right! I ran this twice and I don't get duplicate records because of the objectID
field. What it does is replace all other fields in the object aside from the ID (which in our case will be the subject+code)
but hmmm that's a good point 🤔 wiping it clear and then populating might be good, and switching to replaceAllObjects
seems easy enough
but then it worried me about anything going wrong with the API (e.g. running the script with 202401 currently will return 0 courses to be added since API is not working, so it would simply wipe the index instead of not touching it at all). What do you think?
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.
Also, you'll want to set up synonyms for stuff like ELEC == ECE
and "computer science" == csc
etc., (people do search sometimes spelling the entire subject 🤷 )
subject: course.subject, | ||
code: course.code, |
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.
Having a field that's just the concatenation like objectID
helps with cases where people enter CSC100
without a space.
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.
is objectID
not taken into consideration for the search?
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.
and re: synonyms for courses, are you thinking a sort of look up table with pre defined synonyms for the most common stuff?
Description
This PR adds a TS script to generate a new algolia index and update it so that search has latest data.
I got it to work with my own algolia account and it seems to be working if those are the only fields needed.
It also adds a GH Action script we can dispatch to update the specified term
Closes #444
Checklist