弹性中的 msearch 调用失败,元数据部分不支持 key[size]

问题描述 投票:0回答:1

以下是 msearch post 调用的请求负载:-

{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"*****"}
    {
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "@timestamp": {
              "gte": "1710391896481",
              "lte": "1710413496481",
              "format": "epoch_millis"
            }
          }
        },
        {
          "query_string": {
            "analyze_wildcard": true,
            "query": "*"
          }
        }
      ]
    }
  },
  "aggs": {
    "2": {
      "date_histogram": {
        "fixed_interval": "30s",
        "field": "@timestamp",
        "min_doc_count": 0,
        "extended_bounds": {
          "min": "1710391896481",
          "max": "1710413496481"
        },
        "format": "epoch_millis"
      },
      "aggs": {}
    }
    }
    }

这只在页面加载期间失败一次,之后相同的 api 就可以正常工作了。

API 错误

{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "key [size] is not supported in the metadata section" } ], "type": "illegal_argument_exception", "reason": "key [size] is not supported in the metadata section" }, "status": 400 }

关于如何解决这个问题有什么建议吗?

elasticsearch
1个回答
0
投票

这里有一些提高搜索速度的技巧。

  1. 删除
    query_string
    ,因为它会使用
    *
    过滤所有内容。
  2. 减少aggs结果中的桶数。

1710413496481 - 1710391896481 = 21.600.000 毫秒 = 21.600 秒

21.600 秒/每个桶 30 秒 = 720 个桶

要减少桶的数量,您可以增加

fixed_interval
中的
date_histogram
aggs 或减少
max
min
之间的时间差 时间戳。

© www.soinside.com 2019 - 2024. All rights reserved.