[FEATURE] Expose relevance (BM25) ranking in search results
Description
SortBy currently accepts only DATE, SIZE, INTERNAL_DATE and INGEST_AT.
There is no relevance option, results carry no score field, and with no sort_by
the API returns DATE descending.
I'd like:
- A
RELEVANCEvalue added to theSortByenum. - It used as the default when a text filter (
text/subject/body) is present, keepingDATEas the default for filter-only queries. - Optionally, the BM25 score exposed on each result so clients can display or threshold it.
Bichon already indexes with Tantivy, which computes BM25 scores, so the ranking exists internally — it is just not surfaced through the API or the WebUI.
Purpose / Use Case
and date ordering then buries the best match under the most recent mail. Adding a second term makes a mail harder to find, which is the opposite of what a user expects.
Example on a ~1600-message archive, searching the subject field for a known mail
(PRIMAGAZ : 0100437412 - Bienvenue chez Primagaz !, 2025-01-16):
| Query | Results | Target mail position |
|---|---|---|
bienvenue primagaz |
25 | not on first page |
"bienvenue chez primagaz" |
2 | first |
bienvenue + from: primagaz |
2 | first |
Quoting the exact phrase works, but it requires knowing the precise wording in
advance — which defeats the purpose of searching an archive. The same applies to
falling back on from + date filters.
This matters most on long-term archives, which is exactly Bichon's use case: the larger and older the archive, the more date ordering works against the user.
Additional Information (optional)
Version: 2.0.3 (Docker, rustmailer/bichon:latest).
#215 reports unreliable search more broadly. One comment there ("laserdrucker" alone finds the mail, "laserdrucker brother" returns many mails containing neither term) describes the same OR + date-ordering behaviour. This request is narrower and independent: even with perfect matching, results still need to be ranked by relevance.