diff --git a/packages/backend-core/src/db/lucene.ts b/packages/backend-core/src/db/lucene.ts index 09d0224014..37768e934e 100644 --- a/packages/backend-core/src/db/lucene.ts +++ b/packages/backend-core/src/db/lucene.ts @@ -431,26 +431,28 @@ export class QueryBuilder { }) } if (this.#query.empty) { - build(this.#query.empty, (key: string) => `(*:* -${key}:["" TO *])`) - - // Because the structure of an empty filter looks like this: - // { empty: { someKey: null } } - // - // The check inside of `build` does not set `allFiltersEmpty`, which results - // in weird behaviour when the empty filter is the only filter. We get around - // this by setting `allFiltersEmpty` to false here. - allFiltersEmpty = false + build(this.#query.empty, (key: string) => { + // Because the structure of an empty filter looks like this: + // { empty: { someKey: null } } + // + // The check inside of `build` does not set `allFiltersEmpty`, which results + // in weird behaviour when the empty filter is the only filter. We get around + // this by setting `allFiltersEmpty` to false here. + allFiltersEmpty = false + return `(*:* -${key}:["" TO *])` + }) } if (this.#query.notEmpty) { - build(this.#query.notEmpty, (key: string) => `${key}:["" TO *]`) - - // Because the structure of a notEmpty filter looks like this: - // { notEmpty: { someKey: null } } - // - // The check inside of `build` does not set `allFiltersEmpty`, which results - // in weird behaviour when the empty filter is the only filter. We get around - // this by setting `allFiltersEmpty` to false here. - allFiltersEmpty = false + build(this.#query.notEmpty, (key: string) => { + // Because the structure of a notEmpty filter looks like this: + // { notEmpty: { someKey: null } } + // + // The check inside of `build` does not set `allFiltersEmpty`, which results + // in weird behaviour when the empty filter is the only filter. We get around + // this by setting `allFiltersEmpty` to false here. + allFiltersEmpty = false + return `${key}:["" TO *]` + }) } if (this.#query.oneOf) { build(this.#query.oneOf, oneOf)