bichon icon indicating copy to clipboard operation
bichon copied to clipboard

[FEATURE] Expose relevance (BM25) ranking in search results

Open MrCasquette opened this issue 2 months ago • 0 comments

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:

  1. A RELEVANCE value added to the SortBy enum.
  2. It used as the default when a text filter (text / subject / body) is present, keeping DATE as the default for filter-only queries.
  3. 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.

MrCasquette avatar Sep 18 '26 00:09 MrCasquette