1
0
Fork 0
mirror of synced 2024-07-19 13:15:49 +12:00

Fix client side searching not working due to field prefixes

This commit is contained in:
Andrew Kingston 2022-09-12 09:01:21 +01:00
parent 1bc6f30b6c
commit cc3f4c1221

View file

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