Copy backend implementation for removing key numbering to ensure consistent behaviour
This commit is contained in:
parent
88369a57d8
commit
165c8dd129
|
@ -83,11 +83,13 @@ const cleanupQuery = query => {
|
||||||
/**
|
/**
|
||||||
* Removes a numeric prefix on field names designed to give fields uniqueness
|
* Removes a numeric prefix on field names designed to give fields uniqueness
|
||||||
*/
|
*/
|
||||||
const removeFieldPrefix = field => {
|
const removeKeyNumbering = key => {
|
||||||
if (field && typeof field === "string" && field.includes(":")) {
|
if (typeof key === "string" && key.match(/\d[0-9]*:/g) != null) {
|
||||||
return field.split(":")[1]
|
const parts = key.split(":")
|
||||||
|
parts.shift()
|
||||||
|
return parts.join(":")
|
||||||
} else {
|
} else {
|
||||||
return field
|
return key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +207,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, removeFieldPrefix(key))
|
const docValue = Helpers.deepGet(doc, removeKeyNumbering(key))
|
||||||
if (failFn(docValue, testValue)) {
|
if (failFn(docValue, testValue)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue