Fix client side searching not working due to field prefixes
This commit is contained in:
parent
abe1dd6683
commit
88369a57d8
|
@ -80,6 +80,17 @@ const cleanupQuery = query => {
|
||||||
return 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
|
* Builds a lucene JSON query from the filter structure generated in the builder
|
||||||
* @param filter the builder filter structure
|
* @param filter the builder filter structure
|
||||||
|
@ -194,7 +205,7 @@ export const runLuceneQuery = (docs, query) => {
|
||||||
const filters = Object.entries(query[type] || {})
|
const filters = Object.entries(query[type] || {})
|
||||||
for (let i = 0; i < filters.length; i++) {
|
for (let i = 0; i < filters.length; i++) {
|
||||||
const [key, testValue] = filters[i]
|
const [key, testValue] = filters[i]
|
||||||
const docValue = Helpers.deepGet(doc, key)
|
const docValue = Helpers.deepGet(doc, removeFieldPrefix(key))
|
||||||
if (failFn(docValue, testValue)) {
|
if (failFn(docValue, testValue)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue