diff --git a/public/index.html b/public/index.html
index 5aa7116..b164e66 100644
--- a/public/index.html
+++ b/public/index.html
@@ -197,7 +197,7 @@ pre.raw-line { background: var(--bs-tertiary-bg); padding: .75rem; border-radius
- Use FTS5 syntax: error, "disk full", error NOT warning, auth*
+ Search terms: error 500, "disk full", auth*. Boolean operators like NOT not supported.
diff --git a/src/Storage/Repository.php b/src/Storage/Repository.php
index ac34313..b1614b1 100644
--- a/src/Storage/Repository.php
+++ b/src/Storage/Repository.php
@@ -171,14 +171,34 @@ class Repository
public function searchLogEntries(string $query, int $limit = 200, int $offset = 0): array
{
+ try {
+ $stmt = $this->db->pdo()->prepare(
+ "SELECT e.* FROM log_entries e
+ JOIN log_entries_fts fts ON e.id = fts.rowid
+ WHERE log_entries_fts MATCH ?
+ ORDER BY rank
+ LIMIT ? OFFSET ?"
+ );
+ $stmt->execute([$query, $limit, $offset]);
+ return $stmt->fetchAll();
+ } catch (\PDOException $e) {
+ if (str_contains($e->getMessage(), 'fts5: syntax error')) {
+ return $this->searchLogEntriesLike($query, $limit, $offset);
+ }
+ throw $e;
+ }
+ }
+
+ private function searchLogEntriesLike(string $query, int $limit = 200, int $offset = 0): array
+ {
+ $like = '%' . str_replace(['%', '_'], ['\\%', '\\_'], $query) . '%';
$stmt = $this->db->pdo()->prepare(
"SELECT e.* FROM log_entries e
- JOIN log_entries_fts fts ON e.id = fts.rowid
- WHERE log_entries_fts MATCH ?
- ORDER BY rank
+ WHERE e.line LIKE ?
+ ORDER BY e.created_at DESC
LIMIT ? OFFSET ?"
);
- $stmt->execute([$query, $limit, $offset]);
+ $stmt->execute([$like, $limit, $offset]);
return $stmt->fetchAll();
}