Treat fuzzy search as starts with when operating locally

This commit is contained in:
Andrew Kingston 2021-07-26 12:52:31 +01:00
parent af3802e28a
commit 9ee53f7ee8
1 changed files with 6 additions and 0 deletions

View File

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