“先过滤,然后汇总";还是仅仅是“过滤器汇总"?

编程入门 行业动态 更新时间:2024-10-26 00:19:25
本文介绍了“先过滤,然后汇总";还是仅仅是“过滤器汇总"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近在研究ES,发现可以达到几乎相同的结果,但是对于差异我没有 clear 的想法>在这两个之间.

I am working on ES recently and I found that I could achieve the almost same result but I have no clear idea as to the DIFFERENCE between these two.

先过滤后进行汇总" POST kibana_sample_data_flights/_search { "size": 0, "query": { "constant_score": { "filter": { "term": { "DestCountry": "CA" } } } }, "aggs": { "ca_weathers": { "terms": { "field": "DestWeather" } } } }

过滤器聚合"

POST kibana_sample_data_flights/_search { "size": 0, "aggs": { "ca": { "filter": { "term": { "DestCountry": "CA" } }, "aggs": { "_weathers": { "terms": { "field": "DestWeather" } } } } } }

我的问题

  • 为什么有两个相似的功能?我相信我错了,但是有什么区别呢?(请不要理会结果格式,这不是我要问的问题; p)
  • 如果我想过滤出不相关/不匹配的内容并开始对许多文档进行汇总,哪个会更好?
  • 推荐答案

    @Val的评论,我可能在这里引用以供参考:

    Answer from @Val's comment, I may just quote here for reference:

    在选项A中,汇总将在所有文档上运行.在选项B中,首先对文档进行过滤,并且汇总将仅在所选文档上运行.假设您有1000万个文档,而过滤器只选择了100个,那么很明显,选项B总是会更快.

    In option A, the aggregation will be run on ALL documents. In option B, the documents are first filtered and the aggregation will be run only on the selected documents. Say you have 10M documents and the filter select only a 100, it's pretty evident that option B will always be faster.

    更多推荐

    “先过滤,然后汇总";还是仅仅是“过滤器汇总"?

    本文发布于:2023-10-13 20:33:51,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1489003.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:仅仅是   过滤器   quot

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!