You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Esrally的同一track.json中配置多个搜索查询

EsRally track.json多搜索查询配置解答

完全可以在同一个track.json文件中配置多个搜索查询,你遇到的operation键重复或JSON格式无效报错,是配置结构不符合EsRally规范导致的。

核心配置逻辑

EsRally规定所有测试操作都要放在根层级的operations数组下,每一个搜索查询对应数组内一个独立的operation对象,每个对象单独设置name、operation-type、request等参数即可,只要保证每个operation的name唯一就不会出现键重复问题。

可直接参考的配置示例

{
  "name": "custom-test-track",
  "description": "包含多搜索查询的测试track",
  "indices": [
    // 此处填写你的索引结构、文档映射等配置
  ],
  "operations": [
    // 第一个搜索查询配置
    {
      "name": "term-query-test",
      "operation-type": "search",
      "request": {
        "path": "/test-index/_search",
        "method": "POST",
        "body": {
          "query": {
            "term": {
              "category": "electronics"
            }
          }
        }
      }
    },
    // 第二个搜索查询配置
    {
      "name": "match-query-test",
      "operation-type": "search",
      "request": {
        "path": "/test-index/_search",
        "method": "POST",
        "body": {
          "query": {
            "match": {
              "goods_desc": "high performance"
            }
          }
        }
      }
    }
  ],
  "challenges": [
    // 压测场景配置,可按需指定要运行的查询
    {
      "name": "multi-query-benchmark",
      "description": "同时运行两个搜索查询的压测场景",
      "schedule": [
        {
          "operation": "term-query-test",
          "target-throughput": 100
        },
        {
          "operation": "match-query-test",
          "target-throughput": 80
        }
      ]
    }
  ]
}

常见错误排查点

  • 不要把多个operation对象放在同一个父对象下,必须放到operations数组中
  • 所有operation的name字段必须唯一,不能重名
  • 检查JSON语法,避免漏写、多写逗号,或者括号不匹配的问题

内容的提问来源于stack exchange,提问作者Sameera De Silva

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.11 01:12:03