{"record":{"id":"e91ea81d82a2a371","repo":"mem0ai/mem0","slug":"unsupported-filter-operator-op","errorCode":null,"errorMessage":"Unsupported filter operator: ${op}","messagePattern":"Unsupported filter operator: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/pgvector.ts","lineNumber":118,"sourceCode":"        conditions.push(\"NOT (\" + notGroups.join(\" OR \") + \")\");\n      }\n      continue;\n    }\n\n    const safeKey = escapeFilterKey(key);\n\n    if (value === \"*\") {\n      conditions.push(`payload ? $${paramIndex}`);\n      values.push(key);\n      paramIndex++;\n      continue;\n    }\n\n    if (typeof value === \"object\" && value !== null && !Array.isArray(value)) {\n      for (const [op, opValue] of Object.entries(value)) {\n        const mapping = OPERATOR_SQL_MAP[op];\n        if (!mapping) {\n          throw new Error(`Unsupported filter operator: ${op}`);\n        }\n        const clause = mapping.template\n          .replace(\"%KEY%\", safeKey)\n          .replace(\"%IDX%\", String(paramIndex));\n        conditions.push(clause);\n\n        if (op === \"in\" || op === \"nin\") {\n          values.push((opValue as any[]).map(String));\n        } else if (op === \"contains\" || op === \"icontains\") {\n          const escaped = String(opValue)\n            .replace(/\\\\/g, \"\\\\\\\\\")\n            .replace(/%/g, \"\\\\%\")\n            .replace(/_/g, \"\\\\_\");\n          values.push(`%${escaped}%`);\n        } else if (mapping.numeric) {\n          values.push(Number(opValue));\n        } else {\n          values.push(String(opValue));","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/pgvector.ts#L100-L136","documentation":"When a pgvector SearchFilters value is an object, each key inside it is treated as a comparison operator and looked up in OPERATOR_SQL_MAP. An operator not present in that map throws 'Unsupported filter operator'. Supported operators are those mapped for SQL (eq, ne, gt, gte, lt, lte, in, nin, contains, icontains, etc.).","triggerScenarios":"Passing a nested operator object with a typo or unsupported operator, e.g. filters: { ts: { gteq: 5 } }, { tag: { has: 'x' } }, or { f: { between: [1,2] } } — any object-valued filter whose keys are not recognized comparison operators.","commonSituations":"Typos like 'gteq' or 'lteq'; copying filter syntax from another vector DB (Qdrant/Weaviate style operators) into the pgvector store; assuming Mongo-style '$gte' works here.","solutions":["Correct the operator name to a supported one: eq, ne, gt, gte, lt, lte, in, nin, contains, icontains","Remove the $ prefix if using Mongo-style operators ('$gte' -> 'gte')","For operators like 'between', rewrite as two range conditions combined with AND"],"exampleFix":"// before\nconst r = await vs.search(embedding, { filters: { ts: { $gte: 5 } } });\n\n// after\nconst r = await vs.search(embedding, { filters: { ts: { gte: 5 } } });","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['eq','ne','gt','gte','lt','lte','in','nin','contains','icontains']);\nfunction validateOperators(filters: any): void {\n  for (const v of Object.values(filters ?? {})) {\n    if (v && typeof v === 'object' && !Array.isArray(v)) {\n      for (const op of Object.keys(v)) {\n        if (!SUPPORTED.has(op)) throw new Error(`Unsupported operator: ${op}`);\n      }\n    }\n  }\n}\nvalidateOperators(filters);","typeGuard":"const isSupportedOperator = (op: string): op is 'eq'|'ne'|'gt'|'gte'|'lt'|'lte'|'in'|'nin'|'contains'|'icontains' =>\n  ['eq','ne','gt','gte','lt','lte','in','nin','contains','icontains'].includes(op);","tryCatchPattern":"try { await vs.search(vec, { filters }); } catch (e) { if (e instanceof Error && e.message.startsWith('Unsupported filter operator')) { /* strip/replace bad op, retry once */ } throw e; }","preventionTips":["Type your filters with a shared FilterOperators union so invalid operators fail at compile time","Do not copy operator syntax between vector store backends — supported sets differ","Validate externally supplied filter JSON before it reaches the store"],"tags":["pgvector","search-filters","operator-error","validation","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}