Browse Source

Fix issue with falsey lucene values being ignored

pull/7270/head
Andrew Kingston 4 years ago
parent
commit
77c96b37b3
  1. 11
      packages/frontend-core/src/utils/lucene.js

11
packages/frontend-core/src/utils/lucene.js

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

Loading…
Cancel
Save