SuperAPI AI 工具集

configuring-filters

通用与其它

查看项目

更新于 10-16 03:42

技能介绍

用途:过滤器是记录闸门,决定哪些记录继续通过流水线、哪些被静默丢弃。过滤器直接配置在导出、导入和流程路由分支上,而非独立资源。

四种出现位置:1)输出过滤器(导出 filter),记录从源系统取出后应用,不匹配记录被静默丢弃,所有导出类型可用;2)输入过滤器(查找导出的 inputFilter),在触发查找 API 前应用,不匹配记录跳过查找但不离开流水线,仅当 isLookup: true 时相关;3)导入过滤器(导入 filter),在提交目标系统前应用,不匹配记录被丢弃且不会送达目标;4)分支输入过滤器,配置在流程 routers[].branches[] 上,按分支路由记录,最后一个分支可省略过滤器作为兜底。

机制选择:表达式(type: "expression",filter.expression.rules 数组)适合标准字段比较、模式匹配、空值检查及 and/or 组合;脚本(type: "script",需 filter.script._scriptId 与 filter.script.function)用于复杂业务逻辑、跨记录状态、日期计算和外部 API 调用。优先用表达式。

表达式采用前缀 S 表达式:单条件为 [operator, [extract, fieldName], value];组合用 and/or/not。字段访问用 ["extract", "fieldName"],配置值用 ["settings", "flow.settingName"]。类型转换有 number、string、boolean、epochtime,变换有 lowercase、uppercase、floor、ceiling、abs。运算符包括 equals、notequals、greaterthan、lessthan、contains、startswith、endswith、matches、notempty、empty 等。

CLI 用法:celigo exports set <id> filter.type=expression filter.expression.version=1 filter.expression.rules='["notempty",["extract","email"]]';导入同理;lookup 导出设 inputFilter。复杂过滤器可用 celigo exports update <id> < export-with-filter.json 全量 JSON 更新。移除过滤器用 filter=null。测试用 celigo exports invoke <id> 和 celigo flows run <flowId> -y,再 celigo jobs list 查看 numSuccess、numIgnore、numError。

注意事项:被过滤记录不报错、只计入 numIgnore,排查“记录消失”应先看过滤器;运算符名为 notempty/empty,用 isnotempty/isempty 会静默失配;PUT 会清除未提交字段,建议先 GET 再改;表达式与脚本不可共存;settings 访问器需带作用域前缀;字符串比较默认区分大小写;分支过滤器配置在流程上,用 flows set/update 修改。脚本函数须返回严格 true/false。