jekyll-lunr-js-search icon indicating copy to clipboard operation
jekyll-lunr-js-search copied to clipboard

Search results are not sorted

Open hazenet opened this issue 10 years ago • 3 comments

I am using jekyll-lunr-js-search on my Jekyll test site:

blog.hazenet.dk

But the search results are not sorted in any meaningful way. I have changed the "displaydate" return format in the search.min.js file.

If I search for update, the results are:

03 April 2014 · You're up and running! 03 March 2014 · Hello What Ever 2014 03 March 2015 · You good to go 03 March 2013 · Hello What Ever 2013 03 March 2015 · Hello What Ever 2015

The same issue is also seen on the "official" demo site:

10consulting.com/search

I would actually like to sort on the "pubdate" string, but display the "displaydate" string.

hazenet avatar Jan 06 '15 20:01 hazenet

Agreed that some support for sorting would be nice!

menehune23 avatar Aug 05 '17 05:08 menehune23

Lunr orders search results by their relevance:

Results will be returned sorted by their score, the most relevant results will be returned first. -- Lunr

I'm happy to accept a pull request to provide an override to order results to your preference.

slashdotdash avatar Aug 05 '17 11:08 slashdotdash

Ok thanks, I figured it was something like that. I wonder if there's a way to tweak the settings so that it excludes certain elements from scoring. For instance, if you wanted to match based on title only or something.

It's just a little strange that results like this https://coeurdecode.com/search?q=unity show up in a strange order.

I also wonder if it's not sorting by date as a secondary when two scores are tied.

menehune23 avatar Aug 05 '17 15:08 menehune23