Fix client side searching not working due to field prefixes
This commit is contained in:
parent
1bc6f30b6c
commit
cc3f4c1221
1 changed files with 12 additions and 1 deletions
|
@ -80,6 +80,17 @@ const cleanupQuery = query => {
|
|||
return query
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a numeric prefix on field names designed to give fields uniqueness
|
||||
*/
|
||||
const removeFieldPrefix = field => {
|
||||
if (field && typeof field === "string" && field.includes(":")) {
|
||||
return field.split(":")[1]
|
||||
} else {
|
||||
return field
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a lucene JSON query from the filter structure generated in the builder
|
||||
* @param filter the builder filter structure
|
||||
|
@ -194,7 +205,7 @@ export const runLuceneQuery = (docs, query) => {
|
|||
const filters = Object.entries(query[type] || {})
|
||||
for (let i = 0; i < filters.length; i++) {
|
||||
const [key, testValue] = filters[i]
|
||||
const docValue = Helpers.deepGet(doc, key)
|
||||
const docValue = Helpers.deepGet(doc, removeFieldPrefix(key))
|
||||
if (failFn(docValue, testValue)) {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue