projectEndings / staticSearch

A codebase to support a pure JSON search engine requiring no backend for any XHTML5 document collection
https://endings.uvic.ca/staticSearch/docs/index.html
Mozilla Public License 2.0
46 stars 21 forks source link

Results in chronological order rather than sorted by score #217

Closed martinantonmueller closed 2 years ago

martinantonmueller commented 2 years ago

We edit a diary/journal. So an often used search is to look for the first appearance of a term. Is there a possibility for the output of the search results to be in chronological order rather than based on score?

martindholmes commented 2 years ago

We do have the document sort key feature:

https://endings.uvic.ca/staticSearch/docs/howDoIUseIt.html#configuringDocSortKey

If you create your sort keys as ISO dates, then they will naturally sort in order. However, this is normally overridden by the hit score, so to get a true date-based sort, you may have to override the method SSResultSet~sortByScoreDesc:

https://github.com/projectEndings/staticSearch/blob/v1.4.0/js/SSResultSet.js#L315

to make it disregard the score and use the sort key instead. @joeytakeda, do you think we should make this configurable?

martinantonmueller commented 2 years ago

Perfect! Thank you!

joeytakeda commented 2 years ago

We have a similar ticket for this already: #86 and I think it is certainly something worth revisiting

martindholmes commented 2 years ago

Thanks @joeytakeda I'd forgotten about that ticket. I'm going to close this one and move the discussion over there, because I think there's one very simple config option we could add that would solve the problem.