Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bloovis
Copy link
Contributor

@bloovis bloovis commented Sep 29, 2025

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.

@netlify
Copy link

netlify bot commented Sep 29, 2025

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit f5aa5d7
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/68dabead7700ab000854eb3c
😎 Deploy Preview https://deploy-preview-847--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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,
Copy link
Owner

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?

Copy link
Contributor

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.

Copy link
Owner

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

@bloovis
Copy link
Contributor Author

bloovis commented Oct 6, 2025

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.

joeyundis-altra added a commit to joeyundis-altra/hextra that referenced this pull request Nov 13, 2025
Updated search limits for page and section results to be configurable with sensible defaults.

Per PR imfing#847 on main repo
@joeyundis-altra
Copy link

This PR fixed the issue for me as well.

@yuri1969
Copy link
Contributor

yuri1969 commented Jan 5, 2026

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?

@netlify
Copy link

netlify bot commented Jan 5, 2026

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit c320e8f
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/695c42b8d7f29b00082a2b6c
😎 Deploy Preview https://deploy-preview-847--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@imfing imfing changed the title Work around flexsearch returning fewer than expected result pages. fix: work around flexsearch returning fewer than expected result pages. Jan 5, 2026
@imfing imfing changed the title fix: work around flexsearch returning fewer than expected result pages. fix: work around flexsearch returning fewer than expected result pages Jan 5, 2026
@imfing imfing merged commit c4a3947 into imfing:main Jan 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants