1
0
Fork 0
mirror of synced 2024-06-26 18:10:51 +12:00

Copy backend implementation for removing key numbering to ensure consistent behaviour

This commit is contained in:
Andrew Kingston 2022-09-12 09:07:25 +01:00
parent 88369a57d8
commit 165c8dd129

View file

@ -83,11 +83,13 @@ const cleanupQuery = 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]
const removeKeyNumbering = key => {
if (typeof key === "string" && key.match(/\d[0-9]*:/g) != null) {
const parts = key.split(":")
parts.shift()
return parts.join(":")
} else {
return field
return key
}
}
@ -205,7 +207,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, removeFieldPrefix(key))
const docValue = Helpers.deepGet(doc, removeKeyNumbering(key))
if (failFn(docValue, testValue)) {
return false
}