JMAP text search misses inflected words on the PostgreSQL SearchStore (index and query use different stemming languages)

Issue Description

Email/query with a text filter cannot find messages containing inflected (conjugated/plural)
word forms. The stored PostgreSQL tsvector index is built with the language detected per message
(Dutch for Dutch text), but the search query is executed with a hardcoded English stemming config for
subject/body/attachment fields. Whenever the English and Dutch stems differ, the query lexeme does not
exist in the index and the message is unfindable; even when it literally contains the searched word.

Expected Behavior

Fietsen and fiets should be similiar. Fietsen stem should result in Fiets.
subj @@ to_tsquery(‘dutch’, ‘fietsen’)

Actual Behavior

Fietsen and Fiets results in searching Fiet.

Reproduction Steps

  1. Send two messages to a mailbox:
    message A with subject/body containing the Dutch word fiets
    message B with subject/body containing the Dutch word fietsen
  2. Run a JMAP Email/query with filter: { text: “fiets” }.
    → Finds message A only.
  3. Run a JMAP Email/query with filter: { text: “fietsen” }.
    → Returns 0 results, even though message B literally contains the word fietsen.

Stalwart Version

v0.16.x

Installation Method

Docker

Database Backend

PostgreSQL

Blob Storage

S3-compatible

Search Engine

PostgreSQL

Directory Backend

SQL

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Stalwart tries to automatically detect the language on all queries, however, if the confidence is below 0.3, it defaults to the language configured in defaultLanguage. We did fix an issue in 0.16.18 where, if you had Dutch configured as the default language, it was not properly parsed and reverted to English instead.
In any case, if you do not want to use Dutch as your default language, you can prefix ambiguous/short queries with the language you want, for example nl:fietsen.