-
Notifications
You must be signed in to change notification settings - Fork 193
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: switch typesense sorting to presets #1458
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
onChange={(e) => { | ||
typesenseAdapter.updateConfiguration({ | ||
...typsenseAdapterConfig, | ||
additionalSearchParameters: { | ||
query_by: 'title,description,_tags,instructor_name,contributors', | ||
preset: e.target.value, | ||
}, | ||
}) | ||
|
||
refresh() | ||
}} |
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.
where the magic happens. updates configuration and triggers a search
export const typesenseAdapter = typesenseInstantsearchAdapter() | ||
|
||
const searchClient = typesenseAdapter.searchClient |
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.
need access to the typesenseAdapter
to update configuration
@@ -1,34 +1,29 @@ | |||
import TypesenseInstantSearchAdapter from 'typesense-instantsearch-adapter' | |||
|
|||
export const typsenseAdapterConfig = { |
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.
stuffed the config in an object to spread when we update presets
Since migrating to TypeSense, whenever a user inputs a search or clicks a filter the url is populated by the sorting that we need to do for the content that makes sense.
e.g.
https://egghead.io/q?q=react&sortBy=content_production/sort/_eval([%20(type:playlist):4,%20(type:lesson):3,%20(type:podcast):2],%20(type:talk):1):desc,search_research_sort:asc,rank:asc
The first sorting function is particularly important as it rank sorts playlists to the top before other types of content.
The other way to do this is with presets but @Creeland and I were having a rough time actually setting a preset apart from initial load. Turns out that the TypeSense adapter has an
updateConfiguration
function that we can call when we want to switch to a different preset as recommended here.I'm updating configuration in a select and calling instantsearches
refresh
to trigger another search.