playbook icon indicating copy to clipboard operation
playbook copied to clipboard

Search: match counter

Open yndajas opened this issue 2 years ago • 1 comments

Original search PR: #984

Background

[mostly copied from the original search PR]

Midway through development, we had a matches counter. Unfortunately the search engine we used (Elasticlunr.js) doesn't tell you how many matches it found for the search query (or constituent terms), only a score based on a "very perfect scoring mechanism". So we made our own implementation, counting the matches for the entire search query and displaying it under the heading (alongside breadcrumbs at the time)

However, this didn't account for matches in the title, nor for matches of each of the individual search terms when there were multiple. It should be possible to extend the functionality to achieve this, similar to how the match highlighting has been extended, however the results may still be confusing. The "very perfect scoring mechanism" means that the results are not ordered by a simple count, but some more sophisticated measure of relevance. This means that there might be a result that's higher up than a result with a greater number of matches

In the end, we removed the counter, but it's one to think about

For consideration

Could we do something with the Elasticlunr.js score, or should we implement a more complex (than the one used mid-development) counter of our own, looking at all matches for all terms within the search query, both within the content and the page title?

yndajas avatar Nov 25 '22 12:11 yndajas