1
0
Fork 0
mirror of synced 2024-10-06 04:54:52 +13:00

Fix issue with falsey lucene values being ignored

This commit is contained in:
Andrew Kingston 2022-08-19 14:11:58 +01:00
parent 7eaed5bea7
commit 5c5e4bcccb

View file

@ -72,7 +72,7 @@ const cleanupQuery = query => {
continue
}
for (let [key, value] of Object.entries(query[filterField])) {
if (!value || value === "") {
if (value == null || value === "") {
delete query[filterField][key]
}
}
@ -174,7 +174,7 @@ export const runLuceneQuery = (docs, query) => {
return docs
}
// make query consistent first
// Make query consistent first
query = cleanupQuery(query)
// Iterates over a set of filters and evaluates a fail function against a doc
@ -206,7 +206,12 @@ export const runLuceneQuery = (docs, query) => {
// Process a range match
const rangeMatch = match("range", (docValue, testValue) => {
return !docValue || docValue < testValue.low || docValue > testValue.high
return (
docValue == null ||
docValue === "" ||
docValue < testValue.low ||
docValue > testValue.high
)
})
// Process an equal match (fails if the value is different)