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 <lp@airsupport.dk>
This commit is contained in:
Lars Pagh 2024-02-21 22:59:20 +01:00 • committed by GitHub
parent 8f2b7021a6
commit be04ff01f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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