psyche icon indicating copy to clipboard operation
psyche copied to clipboard

Order results by relevance

Open oscarotero opened this issue 3 years ago • 2 comments

Hi. Is it possible to order the results by relevance? For instance, right now when I search markdown I have the following result: image

The first results are pages from "Getting started" or other pages with the word "markdown" in the content. And the page of the markdown plugin is way down in the results list. I think a page having this word in the title should be more relevant than a page with this word in the content. So I'd like to propose a way rank the results by relevance. For example:

  • If the term is in the title, it has 1.
  • If the term in in the main description, it has 0.5.
  • If the term is in a paragraph, it has 0.2.

This allows to order the page by rank and opens the door to implement in the future more advanced ranking features, like define different weights for different properties, or if the word is repeat, or is at the begining of the content, etc.

oscarotero avatar Jan 31 '22 17:01 oscarotero

For performance, result ordering is done during the indexing process at the moment and sorted according to the site's sitemap/category. This would be useful but again part of a bigger update that would move away from the highly specialised component psyche is at the moment and into a more flexible/fuller search engine, I'll have a go at it during the holidays.

dragonwocky avatar Jan 31 '22 22:01 dragonwocky

Ok, thanks! For inspiration, take a look to Fuse (https://fusejs.io), a great library that provides powerfull search support.

oscarotero avatar Jan 31 '22 22:01 oscarotero