PontusHorn / Pico-Search

Simple search feature for pages in your Pico CMS
MIT License
22 stars 4 forks source link

Rank search results #2

Closed lionkmp closed 5 years ago

lionkmp commented 8 years ago

Hi,

I'm not sure the Pico API will allow this, but I think it would be great to apply a basic ranking to the results, for example:

2 points if word appears in the name of the article 1.5 if appears in the description 1 if in text And then order results by sum of this. Alternatively you can also multiply them with the number of occurrences in each place. If there are more words searched, this could be applied per word, resulting in better match coming up first.

(Or any other raking method you can think of. Currently the search result does not bring up "important" articles first. If you need, I can find the exact numbers in our CMS, it's nothing special, something like the example above.)

Thanks in advance.

PontusHorn commented 8 years ago

Hey,

Valid request! I don't think it'd be a big challenge to add. I don't really need it for my own purposes, and don't have time to do it right now, but I'll probably get to it eventually. Alternatively, I'd be happy to accept a pull request if you're able to contribute the functionality yourself.

PontusHorn commented 5 years ago

Hey @lionkmp,

In case you're still interested in this, I just added some (rather basic) search ranking to the plugin. Let me know if you'd like any specific improvements beyond that. Hope it helps :)