fix types
This commit is contained in:
parent
e3c514e45a
commit
5679acb868
|
@ -391,28 +391,28 @@ export const runLuceneQuery = (docs: any[], query?: SearchQuery) => {
|
||||||
)
|
)
|
||||||
|
|
||||||
const docMatch = (doc: any) => {
|
const docMatch = (doc: any) => {
|
||||||
const filterFunctions = {
|
const filterFunctions: Record<SearchQueryOperators, (doc: any) => boolean> =
|
||||||
string: stringMatch,
|
{
|
||||||
fuzzy: fuzzyMatch,
|
string: stringMatch,
|
||||||
range: rangeMatch,
|
fuzzy: fuzzyMatch,
|
||||||
equal: equalMatch,
|
range: rangeMatch,
|
||||||
notEqual: notEqualMatch,
|
equal: equalMatch,
|
||||||
empty: emptyMatch,
|
notEqual: notEqualMatch,
|
||||||
notEmpty: notEmptyMatch,
|
empty: emptyMatch,
|
||||||
oneOf: oneOf,
|
notEmpty: notEmptyMatch,
|
||||||
contains: contains,
|
oneOf: oneOf,
|
||||||
containsAny: containsAny,
|
contains: contains,
|
||||||
notContains: notContains,
|
containsAny: containsAny,
|
||||||
}
|
notContains: notContains,
|
||||||
const activeFilterKeys: (keyof typeof filterFunctions)[] = Object.entries(
|
}
|
||||||
query
|
|
||||||
)
|
const activeFilterKeys: SearchQueryOperators[] = Object.entries(query)
|
||||||
.filter(
|
.filter(
|
||||||
([key, value]: [string, any]) =>
|
([key, value]: [string, any]) =>
|
||||||
!["allOr", "onEmptyFilter"].includes(key) &&
|
!["allOr", "onEmptyFilter"].includes(key) &&
|
||||||
Object.keys(value as Record<string, any>).length > 0
|
Object.keys(value as Record<string, any>).length > 0
|
||||||
)
|
)
|
||||||
.map(([key]) => key as keyof typeof filterFunctions)
|
.map(([key]) => key as any)
|
||||||
|
|
||||||
const results: boolean[] = activeFilterKeys.map(filterKey => {
|
const results: boolean[] = activeFilterKeys.map(filterKey => {
|
||||||
const filterFunction = filterFunctions[filterKey]
|
const filterFunction = filterFunctions[filterKey]
|
||||||
|
|
Loading…
Reference in New Issue