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

Weights ignored? #729

Open
thebrightsideofmathematics opened this issue Oct 16, 2024 · 6 comments
Open

Weights ignored? #729

thebrightsideofmathematics opened this issue Oct 16, 2024 · 6 comments

Comments

@thebrightsideofmathematics
Copy link

thebrightsideofmathematics commented Oct 16, 2024

I've updated from 1.0.4 to 1.1.1 and apparently my setup with adding data-pagefind-weight="2" to different elements does not work anymore. My top results in the search are pages that should be low in priority since I gave them weights of 0.01. Did the version change something or is it just my machine?

@bglw
Copy link
Contributor

bglw commented Oct 16, 2024

👋 @thebrightsideofmathematics

Yes, the v1.1.0 release changed much of the ranking algorithm. You can see the release notes for this here: https://github.com/CloudCannon/pagefind/releases/tag/v1.1.0

I wouldn't expect the weighting to be quite as dramatically different in your case though — do you have a site you can share and I can take a look?

@thebrightsideofmathematics
Copy link
Author

Thanks for the answer! That explains my confusion. I try to setup a short example! Is there a better possibility in the new release to put some pages low in priority?

@thebrightsideofmathematics
Copy link
Author

thebrightsideofmathematics commented Oct 18, 2024

I tried to create a minimal example but including too few pages didn't show the behaviour I noticed before. Indeed, in this case, 1.0.4 and 1.1.1 show the same sorting.

@bglw
Copy link
Contributor

bglw commented Nov 20, 2024

I'm going to look at the ranking again in an upcoming release, to resolve some of the current issues around lack of control. I'll update here when I do :)

@juancampa
Copy link

juancampa commented Jan 3, 2025

I think we're seeing the same issue on our site. We're setting the weight of an h2 to 10 with the expectation to make it show up at the top when the search term exactly matches a word in it. Is this a reasonable expectation in the first place?

More details:
version: 1.3.0 (using @pagefind/default-ui)
website: docs.membrane.io
search term: "Gref"

A user would expect the highlighted page (with weight 10) to be at the top but it shows third

Screenshot 2025-01-02 at 22 50 24

The header in question is getting a weight like this:

<h2 data-pagefind-weight="10" id="grefs">Grefs</h2>

@juancampa
Copy link

juancampa commented Jan 3, 2025

Ok, I think I know what the issue is: it appears that the terms that appear in header tags (in our case <h2>) are being ignored. It works if I move the weight to a <span> right below it like this:

<h2 id="grefs">Grefs</h2>
<span data-pagefind-weight="6">Grefs</span>

Note that the span was already there, I just added a weight to it

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

No branches or pull requests

3 participants