-
-
Notifications
You must be signed in to change notification settings - Fork 384
fix: work around flexsearch returning fewer than expected result pages #847
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
Conversation
✅ Deploy Preview for hugo-hextra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
||
| // Show the top 5 results for each page | ||
| const sectionResults = window.sectionIndex.search(query, 5, { enrich: true, suggest: true, tag: { 'pageId': `page_${result.id}` } })[0]?.result || []; | ||
| const sectionResults = window.sectionIndex.search(query, |
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.
do we need to pass the limit here as the second argument?
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.
Based on brief testing, the fix appears to work only when no limit is passed.
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.
got it, I'll do a quick look, and merge it after
|
As I mentioned in issue 714, if you pass a limit to the search of the sectionIndex, it limits the total number of section results for all pages, not just for that one page. This appears to be a bug in FlexSearch itself. That's why I don't use a limit, and because of the bug, I don't know how to set a sensible limit. Should it be 5 * maxPageResults? That's an arbitrary limit that might be wrong for pages that have more than 5 sections that match the search. I realize this is a very strange bug, and it still makes my head hurt a little, but I don't know what else to do about it. |
Updated search limits for page and section results to be configurable with sensible defaults. Per PR imfing#847 on main repo
|
This PR fixed the issue for me as well. |
|
This PR also works for me - it resolves the annoying issue that caused the majority of search hits to be missing. @imfing Can we get this reviewed, please? |
✅ Deploy Preview for hugo-hextra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This is my fix for the problem described in issue 714. I am a Javascript newbie (though I've been working in assembly language and C since 1976), so there are likely better ways to do things.
I also see that my commit comment doesn't follow the expected norms, which I was not aware of until 10 seconds ago.