--- title: "Rollup 搜索功能开关配置" date: 2026-02-26 lastmod: 2026-02-26 description: "rollup.search.enabled 配置项用于控制是否启用 Rollup 搜索功能。" tags: ["Rollup", "搜索", "功能开关"] summary: "配置项作用 # rollup.search.enabled 配置项用于控制是否启用 Rollup 搜索功能。 当启用时,系统会启动 RollupListener 组件,该组件负责处理包含 Rollup 索引的搜索请求,自动将查询重写为同时查询原始索引和 Rollup 索引。 配置项属性 # 配置路径: rollup.search.enabled 数据类型: Boolean(布尔值) 默认值: false 是否可选: 是 作用域: NodeScope(节点级别) 动态更新: 是(可以动态更新,无需重启) 配置项详解 # 工作机制 # Rollup 搜索功能启用流程 enabled: true (启用): 启动流程: ├── 节点启动 ├── 加载配置 ├── 检查 rollup.search.enabled ├── 为 true? │ ├── 启动 RollupListener ✅ │ │ ├── 注册搜索拦截器 │ │ ├── 监听搜索请求 │ │ └── 重写 Rollup 查询 │ └── 功能可用 └── ." --- ## 配置项作用 `rollup.search.enabled` 配置项用于控制**是否启用 Rollup 搜索功能**。 当启用时,系统会启动 `RollupListener` 组件,该组件负责处理包含 Rollup 索引的搜索请求,自动将查询重写为同时查询原始索引和 Rollup 索引。 ## 配置项属性 - **配置路径**: `rollup.search.enabled` - **数据类型**: `Boolean`(布尔值) - **默认值**: `false` - **是否可选**: 是 - **作用域**: NodeScope(节点级别) - **动态更新**: 是(可以动态更新,无需重启) ## 配置项详解 ## 工作机制 ``` Rollup 搜索功能启用流程 enabled: true (启用): 启动流程: ├── 节点启动 ├── 加载配置 ├── 检查 rollup.search.enabled ├── 为 true? │ ├── 启动 RollupListener ✅ │ │ ├── 注册搜索拦截器 │ │ ├── 监听搜索请求 │ │ └── 重写 Rollup 查询 │ └── 功能可用 └── ... enabled: false (禁用): 启动流程: ├── 节点启动 ├── 加载配置 ├── 检查 rollup.search.enabled ├── 为 true? │ ├── 否 │ └── 不启动 RollupListener ❌ └── Rollup 搜索不可用 ``` ## 搜索重写机制 ``` Rollup 搜索请求处理 原始搜索请求: POST /original_index/_search { "query": { ... } } │ ├── RollupListener 拦截 │ ├── 识别 Rollup 索引 │ ├── 分析查询字段 │ └── 重写查询 │ └── 重写后搜索: ├── 原始索引查询 ├── Rollup 索引查询 └── 合并结果 功能启用后: ├── 自动处理 Rollup 索引 ├── 对用户透明 ├── 无需修改查询 └── 结果自动合并 ``` ## 状态切换 ``` 动态切换功能 从 false 切换到 true: ├── 动态更新配置 ├── 启动 RollupListener ├── 注册组件 └── 功能生效 ✅ 从 true 切换到 false: ├── 动态更新配置 ├── 停止 RollupListener ├── 注销组件 └── 功能禁用 ❌ ``` ## 配置建议 ## 生产环境(使用 Rollup) ```yaml rollup: search: enabled: true # 启用 Rollup 搜索 ``` **建议**: 使用 Rollup 功能时应启用,以支持 Rollup 索引查询。 ## 不使用 Rollup ```yaml rollup: search: enabled: false # 禁用(默认) ``` **建议**: 不使用 Rollup 功能时保持禁用,减少资源消耗。 ## 开发测试 ```yaml rollup: search: enabled: true # 测试时启用 ``` **建议**: 测试环境可以启用以验证功能。 ## 代码示例 ## 基础配置 ```yaml rollup: search: enabled: true ``` ## 动态更新 ```json PUT /_cluster/settings { "transient": { "rollup.search.enabled": true } } ``` ## 完整 Rollup 搜索配置 ```yaml rollup: search: enabled: true max_count: 2 search_all_jobs: false backoff_count: 5 backoff_millis: 1000 ``` ## 禁用功能 ```json PUT /_cluster/settings { "transient": { "rollup.search.enabled": false } } ``` ## 相关配置 | 配置项 | 作用 | 默认值 | |--------|------|--------| | `search.enabled` | 搜索功能开关 | false | | `search.max_count` | 最大搜索数量 | 2 | | `search.search_all_jobs` | 搜索所有任务 | false | | `search.backoff_count` | 重试次数 | 5 | | `search.backoff_millis` | 重试延迟 | 1000ms | ## 注意事项 1. **默认禁用**: 默认值为 `false`,需要显式启用。 2. **动态更新**: 支持动态更新,无需重启节点。 3. **节点级别**: 每个节点需要单独配置,确保集群中所有节点配置一致。 4. **功能依赖**: 使用 Rollup 搜索功能时必须启用。 5. **资源消耗**: 启用后会增加少量内存和 CPU 开销。 6. **查询透明**: 启用后对查询请求透明,用户无需修改查询代码。 7. **结果合并**: 系统自动合并原始索引和 Rollup 索引的结果。 8. **配置一致性**: 集群中所有节点应保持相同配置。 9. **监控建议**: 监控 Rollup 搜索请求的性能指标。 10. **测试验证**: 启用前应在测试环境验证功能。