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

Elasticsearch带runtime mapping的聚合查询异常:仅size=0时生效

问题:Runtime Mapping查询聚合异常:仅size=0时返回正确结果

3节点集群中,某索引包含160k+文档。当使用runtime mapping执行查询与聚合操作时,仅能返回命中结果,甚至未对结果进行过滤;仅当设置size=0时,操作才能正常执行。

示例场景

  • 通过runtime mapping计算两个字段
  • 查询将文档过滤至2.7k条
  • 配置聚合操作

请求结构

{
  "size": 1,
  "runtime_mappings": {},
  "query": {},
  "aggs": {}
}

异常情况(size=1)

返回结果仅包含命中数据,total值显示为10000(relation为gte),无聚合结果:

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : 1.0,
    "hits" : []
  }
}

正常情况(size=0)

返回结果包含正确的total值(2731,relation为eq)及聚合结果:

{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2731,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : []
}

有没有人遇到过这类问题?恳请各位提供帮助,非常感谢。

内容的提问来源于stack exchange,提问作者Nour Borgi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 14:35:07