ES解決too_many_buckets_exception異常


  • 說明:在做es的聚合查詢時,當數據基數非常大,或者查詢語句不合理會導致es的查詢很吃力,甚至出現以下錯誤。但有時候確實需要這么查詢,這個時候需要修改max_buckets的閾值。
{
    "error": {
        "root_cause": [],
        "type": "search_phase_execution_exception",
        "reason": "",
        "phase": "fetch",
        "grouped": true,
        "failed_shards": [],
        "caused_by": {
            "type": "too_many_buckets_exception",
            "reason": "Trying to create too many buckets. Must be less than or equal to: [65535] but was [2191545]. This limit can be set by changing the [search.max_buckets] cluster level setting.",
            "max_buckets": 65535
        }
    },
    "status": 503
}

 

  • 通過 GET /_cluster/settings 可以查看max_buckets的閾值
{
  "persistent" : {
    "search" : {
      "max_buckets" : "10000"
    },
    "xpack" : {
      "monitoring" : {
        "collection" : {
          "enabled" : "true"
        }
      }
    }
  },
  "transient" : {
    "search" : {
      "max_buckets" : "10000"
    }
  }
}
 
        
  • 修改方案:通過修改persistent和transient來配置max_buckets的值。
PUT /_cluster/settings
{
  "persistent": {
    "search.max_buckets": 1000000
  }
}


PUT /_cluster/settings
{
  "transient": {
    "search.max_buckets": 1000000
  }
}



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM