Copy backend implementation for removing key numbering to ensure consistent behaviour
This commit is contained in:
parent
cc3f4c1221
commit
899aea9d00
1 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue