Create Pagefind ranking playground
Ranking is a bit of an opaque box at the moment, and making changes to the algorithm can be hard without good confidence in the end result.
The first step to being able to do this is to create some kind of ranking playground for Pagefind. The exact format of this is up for discussion, but at a minimum it should allow searching an example (or ideally user-supplied) index, while changing the ranking parameters live to see how they affect the results. It should also provide deeper debug information on the scoring for each result.
A while ago I set up a Rust playground containing the core essentials of the ranking, which can be seen here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=be766fc0ffe54b9981587d2a8fe6dafe
This playground allows us to change the code itself, which is useful, though it isn't a great space to visualize searches of a larger real-world index.
This would be super helpful! I just spent some time tweaking our search results and ended up giving up. In part is because we're using @astro/starlight and the build/test cycle takes a little bit too long. Having a quick feedback loop would be awesome.
Something that would be useful to have in the playground is how the excerpts are determined. I was hoping that a term with weight 10 would be selected but that never worked, instead the <h1> term was always picked because it came back from the backend with a very high balanced_score.
I should say that it's possible that it's an issue with how @astro/starlight feeds pagefind though. I need to look into it.
The initial cut of the Playground exists on the latest alpha release βΒ and has already revealed some changes I need to make π
Anyone can explore the playground for the docs site here: https://unreleased.pagefind.app/pagefind/playground/
Something that would be useful to have in the playground is how the excerpts are determined
Good idea! I'll keep that one in mind. Excerpts don't currently use any of the weights, but I agree they should.
π This has shipped in Pagefind v1.4.0 π