nextcloud / nextcloud/mail

Search box finds nothing unless I clear every field except "body"

Open
#13,068 1 comment 0 reactions 1 assignee View on GitHub

@GretaD is already working on this.

Since Jun 17, 2026.

3. to review bug
Dominant language
JavaScript
Stars
1k
Forks
348
Avg merge
12h 28m
Merged PRs (30d)
91

Description

Steps to reproduce

If I type a word in the search box above the message list, I get zero results,
even when I'm staring at a message that clearly contains that word in its body.

The only way I found to make it work: open the advanced search panel, delete the
word from Subject, From and To by hand, and leave it only in Body. Then the
message shows up. So the search box is basically unusable as-is.

I have "Enable mail body search" turned on for the account, and my IMAP server
(Dovecot with flatcurve) does have a working full-text index. doveadm search
on the server finds the message by body just fine, so this is on the Mail app side.

Steps to reproduce
  1. Enable "Enable mail body search" on an account.
  2. Open a folder.
  3. Search for a word that's in the body of a message but not in its subject,
    sender or recipient.
  4. Nothing comes up.
  5. Open advanced search, remove the word from Subject / From / To, keep it only
    in Body, search again -> the message is found.
Expected behavior

Typing one word in the search box should find messages that have that word in any
field (subject, sender, recipient or body). A plain OR.

Actual behavior

The search box puts the same word into Subject, From, To AND Body at once, and then
combines them with AND. So it ends up asking for a message where the word is in the
sender AND the recipient AND (subject OR body) all at the same time, which never
happens for a normal email.

Mail app version

5.9.2

Nextcloud version

33.0.3

Mailserver or service

IMAP: Dovecot (Mailcow) + flatcurve FTS (mailcow)

Operating system

AIO

PHP engine version

None

Nextcloud memory caching

No response

Web server

None

Database

None

Additional info
Where it comes from (I went digging)
  • The quick search fills every field with the same query: searchInSubject = query,
    searchInFrom = [{email: query}], searchInTo = [{email: query}],
    searchInMessageBody = searchBody ? query : null.
  • The default match mode is allof (AND): SearchQuery.php has
    private string $match = 'allof';, and the frontend resetFilter() sets
    this.match = "allof".
  • In MessageMapper::findIdsByQuery(), with allof, From and To each become their
    own andWhere(...), while Subject and Body are OR'd together. Net result is
    From~term AND To~term AND (Subject~term OR Body~term).

Switching the single-term search to anyof would put all four into the OR group and
fix it. allof only makes sense in the advanced panel when you fill different fields
with different values.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.