From fc75983e641337dd38f9fa528f611135a7fa2cf5 Mon Sep 17 00:00:00 2001 From: Luis Alberto Santos Date: Sun, 14 May 2023 18:56:35 +0200 Subject: [PATCH] improve search algorithm ordering --- src/storage.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/storage.rs b/src/storage.rs index e88f8cc..4a7dc92 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -309,7 +309,7 @@ impl SqliteStorage { SELECT c.rowid, c.category, c.alias, c.cmd, c.description, c.usage, 2 as ord FROM command_fts s JOIN command c ON s.rowid = c.rowid - WHERE command_fts MATCH :match_ordered + WHERE command_fts MATCH :match_cmd_ordered UNION ALL @@ -329,8 +329,8 @@ impl SqliteStorage { "#, )?; - let match_ordered = format!( - "^{}", + let match_cmd_ordered = format!( + "\"flat_cmd\" : ^{}", flat_search .split_whitespace() .map(|token| format!("{token}*")) @@ -347,7 +347,7 @@ impl SqliteStorage { let commands = stmt .query(&[ - (":match_ordered", &match_ordered), + (":match_cmd_ordered", &match_cmd_ordered), (":match_simple", &match_simple), (":glob", &glob), ])?