Fix minor issue in searchMessages

This commit is contained in:
Fedor Indutny 2024-02-27 08:11:49 -08:00 committed by GitHub
parent 167b2f4f1c
commit bbf04f2fbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1762,6 +1762,11 @@ async function searchMessages({
.map(token => `"${token.replace(/"/g, '""')}"*`)
.join(' ');
// FTS5 is not happy about empty "MATCH" so short-circuit early.
if (!normalizedQuery) {
return [];
}
// sqlite queries with a join on a virtual table (like FTS5) are de-optimized
// and can't use indices for ordering results. Instead an in-memory index of
// the join rows is sorted on the fly, and this becomes substantially