Elasticsearch查询参数batched_reduce_size的解释

鄙人的新书《Elasticsearch权威指南》正式出版发行,欢迎购买!本书由华为、中兴高级技术专家全面审读并撰序,助您挑战百万年薪 购书链接: Elasticsearch查询参数batched_reduce_size的解释_第1张图片

《Elasticsearch权威指南》

欢迎关注鄙人公众号,技术干货随时看!
Elasticsearch查询参数batched_reduce_size的解释_第2张图片

  当我们使用Elasticsearch查询数据时,如果数据量非常大时,会命中大量分片中的大量数据,可能会造成集群内存异常,此时可以通过一个高级参数batched_reduce_size进行控制。使用方法如下:

GET user_order/_search?q=user:kimchy&batched_reduce_size=256

或者:

POST  /user_order/_search
{
    "query" : {
        "term" : { "user" : "kimchy"}
        "batched_reduce_size":256
    }
}

  关于batched_reduce_size参数,官网英文的解释:
(Optional, integer) The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.

  如果对Elasticsearch的原理没有一定的理解,这段英文理解起来有点困难。batched_reduce_size具体的用途和含义如下:
  此参数用来限制协调节点(也就是接受请求的节点)一次(批)处理的分片数量,如果命中的分片数量大于此参数值,则会分批执行,默认值为512。如果请求中潜在的分片数量很大,则应将此值用作保护机制,以减少每个搜索请求的内存开销。

你可能感兴趣的:(elasticsearch,Elasticsearch,内存溢出)