Skip to content
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

adjust fuse threshold in offline search to better filter out irrelevant results #1183

Merged
merged 4 commits into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions www-offline/layouts/search/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ <h3 class="col-3 text-center m-auto">Start typing to search</h3>
const Fuse = window.Fuse
const searchOptions = {
shouldSort: true,
threshold: 0.4,
location: 0,
distance: 100,
matchAllTokens: true,
ignoreLocation: true,
includeScore: true,
maxPatternLength: 32,
threshold: 0.2,
minMatchCharLength: 3,
keys: ["title", "primary_course_number"]
}
Expand All @@ -87,6 +84,7 @@ <h3 class="col-3 text-center m-auto">Start typing to search</h3>
const searchButton = document.getElementById("search-button")
const performSearch = searchString => {
const searchResults = fuse.search(searchString)
const searchResultsSection = document.getElementById("search-results")
if (searchResults.length > 0) {
const searchResultComponents = searchResults.map(searchResult => {
return `
Expand All @@ -109,7 +107,6 @@ <h3 class="col-3 text-center m-auto">Start typing to search</h3>
</article>
`
})
const searchResultsSection = document.getElementById("search-results")
searchResultsSection.innerHTML = searchResultComponents.join("")
}
else {
Expand Down