fromthepage
fromthepage copied to clipboard
Let researchers change search result order
Currently the search results across a collection or within a work do not display in a logical order. (cf. #2188 and #2091)
We should provide a way for users to re-order search results to support the following cases:
- Search engine-style/independent pages In this case pages should be displayed by order of relevance. If a search is collection-wide, we should display the most relevant pages regardless of the work they appear in, and perhaps de-prioritize the work title in the result page.
-
Index-style/preserve continuity To facilitate reading relevant portions of a narrative, we should display pages in the order in which they appear within a work (codicological order). For collection-wide search, we should group pages within works, and order the works as logically as possible -- by document date (if present) or by title or by
external_id
.
We should test this with faceted browsing as well.
@sylvieed can you think about this?
Search-engine style: Currently, we use fulltext boolean searches to search pages by text. We use the +
operator for this (like +"search string"
), which requires that the text contain the exact phrase of the search term (with nothing inbetween). This means that all of the results will have the same 'relevance' unless any of them contain the phrase multiple times. If we want to sort by relevance, we should use a different operator, like >
: +(>search >string)
so that pages with more of the search terms would be ranked higher & sorting by relevance would make more sense. If we wanted to put more effort into this, we could allow for search queries with quotes, like Google, "search string"
to match exactly that phrase -- which should work like our searches do now. (#2360)
Having the project owner decide which of these result styles to show for their collection seems like the best idea. If we want to make search more complex, we could make this choice the default, and then add an option ('sort by'?) on a user's search.
For development, I think this would get pretty complicated. There are a few tasks, none of which are particularly easy:
- Adding relevance-based search
- Adding choice of search style in backend -- we would need to update the SearchAttempt model with this
- Adding choice of search style in UI -- we have no precedent for this
- Distinguishing between search styles in UI -- the relevance-sorted results should not emphasize the work names, but the index-style results should