From 9ee53f7ee8126763e469d4cb1430becc36f3a660 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 26 Jul 2021 12:52:31 +0100 Subject: [PATCH] Treat fuzzy search as starts with when operating locally --- packages/standard-components/src/lucene.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/standard-components/src/lucene.js b/packages/standard-components/src/lucene.js index 91c69dfda2..855a221cf1 100644 --- a/packages/standard-components/src/lucene.js +++ b/packages/standard-components/src/lucene.js @@ -85,6 +85,11 @@ export const luceneQuery = (docs, query) => { return !doc[key] || !doc[key].startsWith(value) }) + // Process a fuzzy match (treat the same as starts with when running locally) + const fuzzyMatch = match("fuzzy", (key, value, doc) => { + return !doc[key] || !doc[key].startsWith(value) + }) + // Process a range match const rangeMatch = match("range", (key, value, doc) => { return !doc[key] || doc[key] < value.low || doc[key] > value.high @@ -114,6 +119,7 @@ export const luceneQuery = (docs, query) => { const docMatch = doc => { return ( stringMatch(doc) && + fuzzyMatch(doc) && rangeMatch(doc) && equalMatch(doc) && notEqualMatch(doc) &&