Betterbird Blog

What’s going on in the project

How Betterbird saves you time: Search improvements

- Posted in Features by

Message search in Thunderbird and Betterbird is a widely misunderstood area. Both programs offer three different searches:

  • "Regular" message search, via the context menu "Search Messages..." or keyboard shortcut Ctrl+Shift+F. This searches in a folder, all folders of an account, or all folders in all mail accounts. The latter is a recent enhancement in Betterbird. This method is also used to create "(Saved) Search Folders", which together with "Unified Folders" form the class of "Virtual Folders".
  • Quick Filter Search, QF in short, which is summoned with keyboard shortcut Ctrl+Shift+K. This search uses the same technology as message search under the hood.
  • Last not least, there is "Global Search and Indexer", for short, "Gloda" (Global Database), which indexes all mail and chat message into a global SQLite database global-messages-db.sqlite. When enabled, this is summoned with keyboard shortcut Ctrl+K.

Betterbird offers many improvements in message, QF search and virtual folders:

  • In message search, it offers complex search terms (and/or grouping) and regular expression search.
  • In both message search and QF, diacritics are ignores, so "señor" matches "senor". Bodies of encrypted messages are also searched.
  • QF offers negations (inverted buttons) and better feedback while the search is running.
  • Virtual folders are fully cached: When a virtual folder is opened, it is restored from cache instead of executing the underlying search again which can lead to extreme performance degradation if the virtual folder is based on many and large folders.

Now turning our attention to Gloda. It was developed in 2009 in series of tickets and currently has 45 open bugs and enhancement requests. Since the initial developer left the project, the code is basically unmaintained, is has only received general refactoring, for example when the entire Thunderbird codebase was migrated to custom elements and ECMAScript Modules. Gloda is the only code left that still uses JavaScript Generator Functions. They have been replaced with modern asynchronous processing in the rest of the codebase. In brief: Thunderbird developers will only touch Gloda with a ten-foot pole, and the same goes for the Betterbird team. That said, our project leader had some exposure to the Gloda code, for example, when he was the Thunderbird maintainer and had to fight inadvertent changes to the tokenizer that broke Gloda completely.

Despite all the difficulties, Betterbird offers a few discrete improvements:

  • Gloda search in encrypted messages
  • Gloda results can immediately be opened in a list view
  • Gloda skips duplicate results in Gmail's "All Mail" folder
  • Preference mailnews.database.global.indexer.max_body_part_size to allow Golda to index more than the first 20 KB of a message to avoid missed search hits
  • And the most recent improvement: Two new filters which allow restricting the search result to search hits which matched on message subject or message body. Fortunately, ChatGPT sprang to help to make sense of the code.