diff --git a/packages/backend-core/src/db/lucene.ts b/packages/backend-core/src/db/lucene.ts index 6f2f4fc991..5d21d4f4e4 100644 --- a/packages/backend-core/src/db/lucene.ts +++ b/packages/backend-core/src/db/lucene.ts @@ -243,7 +243,7 @@ export class QueryBuilder { } // Escape characters if (!this.#noEscaping && escape && originalType === "string") { - value = `${value}`.replace(/[ #+\-&|!(){}\]^"~*?:\\]/g, "\\$&") + value = `${value}`.replace(/[ \/#+\-&|!(){}\]^"~*?:\\]/g, "\\$&") } // Wrap in quotes @@ -320,6 +320,18 @@ export class QueryBuilder { return `${key}:(${statement})` } + const fuzzy = (key: string, value: any) => { + if (!value) { + return null + } + value = builder.preprocess(value, { + escape: true, + lowercase: true, + type: "fuzzy", + }) + return `${key}:/.*${value}.*/` + } + const notContains = (key: string, value: any) => { const allPrefix = allOr ? "*:* AND " : "" const mode = allOr ? "AND" : undefined @@ -408,17 +420,7 @@ export class QueryBuilder { }) } if (this.#query.fuzzy) { - build(this.#query.fuzzy, (key: string, value: any) => { - if (!value) { - return null - } - value = builder.preprocess(value, { - escape: true, - lowercase: true, - type: "fuzzy", - }) - return `${key}:${value}~` - }) + build(this.#query.fuzzy, fuzzy) } if (this.#query.equal) { build(this.#query.equal, equal) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 34186cf554..20d79195f1 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -54,13 +54,8 @@ export const getValidOperatorsForType = ( ops = stringOps.concat([Op.MoreThan, Op.LessThan]) } - // Filter out "like" for internal tables - const externalTable = datasource?.tableId?.includes("datasource_plus") - if (datasource?.type === "table" && !externalTable) { - ops = ops.filter(x => x !== Op.Like) - } - // Only allow equal/not equal for _id in SQL tables + const externalTable = datasource?.tableId?.includes("datasource_plus") if (field === "_id" && externalTable) { ops = [Op.Equals, Op.NotEquals, Op.In] }