From be04ff01f833f6191bb16d2cb80c6b90ea54363b Mon Sep 17 00:00:00 2001 From: Lars Pagh Date: Wed, 21 Feb 2024 22:59:20 +0100 Subject: [PATCH 1/2] Fix full-text search containg special characters (#876) Previously the `ftsIndex.retrieve` would fail if any of the search terms contain characters like dots. This would be the case where you use the `folder` context provider searching using a folder containing dots. Now we wrap each search term in double-quotes before joining them with `OR`. This forces dots to be considered as part of the literal search term. Co-authored-by: Lars Pagh --- core/context/retrieval.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/context/retrieval.ts b/core/context/retrieval.ts index 6d9a26925..547977257 100644 --- a/core/context/retrieval.ts +++ b/core/context/retrieval.ts @@ -137,7 +137,7 @@ export async function retrieveContextItemsFromEmbeddings( if (extras.fullInput.trim() !== "") { ftsResults = await ftsIndex.retrieve( tags, - extras.fullInput.trim().split(" ").join(" OR "), + extras.fullInput.trim().split(" ").map(element => `"${element}"`).join(" OR "), nRetrieve / 2, filterDirectory, undefined From ad219071c990443ead698b2a668d39630ebac021 Mon Sep 17 00:00:00 2001 From: Lars Pagh Date: Wed, 21 Feb 2024 23:01:56 +0100 Subject: [PATCH 2/2] Fix markComplete removal (#874) MarkComplete is called for every added, removed or changed item found. Therefore it seems odd (ignoring the performance perspective) that we try to remove all items at once. The other cases also only handle one single item at the time. Nevertheless the "remove" case did not behave as expected and did not remove anything from the tag_catalog. With the code change we now handle one single item at the time and the item is removed from the tag_catalog as expected. Co-authored-by: Lars Pagh --- core/indexing/refreshIndex.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/indexing/refreshIndex.ts b/core/indexing/refreshIndex.ts index ca8fd97eb..97bb0d2a3 100644 --- a/core/indexing/refreshIndex.ts +++ b/core/indexing/refreshIndex.ts @@ -165,12 +165,14 @@ async function getAddRemoveForTag( case AddRemoveResultType.Remove: await db.run( `DELETE FROM tag_catalog WHERE - path IN (?) AND + cacheKey = ? AND + path = ? AND dir = ? AND branch = ? AND artifactId = ? `, - remove.map((r) => `'${r.path}'`).join(", "), + cacheKey, + path, tag.directory, tag.branch, tag.artifactId