ES中的收集器(百分位/基数)

org.elasticsearch.search.query.QueryPhase#executeInternal 

            final LinkedList<QueryCollectorContext> collectors = new LinkedList<>();
            // whether the chain contains a collector that filters documents
            boolean hasFilterCollector = false;
            if (searchContext.terminateAfter() != SearchContext.DEFAULT_TERMINATE_AFTER) {
                // add terminate_after before the filter collectors
                // it will only be applied on documents accepted by these filter collectors
                collectors.add(createEarlyTerminationCollectorContext(searchContext.terminateAfter()));
                // this collector can filter documents during the collection
                hasFilterCollector = true;
            }
            if (searchContext.parsedPostFilter() != null) {
                // add post filters before aggregations
                // it will only be applied to top hits
                collectors.add(createFilteredCollectorContext(searcher, searchContext.parsedPostFilter().query()));
                // this collector can filter documents during the collection
                hasFilterCollector = true;
            }
            if (searchContext.queryCollectors().isEmpty() == false) {
                // plug in additional collectors, like aggregations
                collectors.add(createMultiCollectorContext(searchContext.queryCollectors().values()));
            }
            if (searchContext.minimumScore() != null) {
                // apply the minimum score after multi collector so we filter aggs as well
                collectors.add(createMinScoreCollectorContext(searchContext.minimumScore()));
                // this collector can filter documents during the collection
                hasFilterCollector = true;
            }

org.elasticsearch.search.query.QueryPhase#searchWithCollector 

        // create the top docs collector last when the other collectors are known
        final TopDocsCollectorContext topDocsFactory = createTopDocsCollectorContext(searchContext, hasFilterCollector);
        // add the top docs collector, the first collector context in the chain
        collectors.addFirst(topDocsFactory);
{
  "min_score": 10,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "speaker": "HOTSPUR"
          }
        }
      ]
    }
  },
  "post_filter": {
    "term": {
      "speaker": "HOTSPUR"
    }
  },
  "aggs": {
    "all_colors": {
      "terms": {
        "field": "speaker",
        "size": 200
      }
    }
  }
}

    /**
     * Creates the collector tree from the provided <code>collectors</code>
     * @param collectors Ordered list of collector context
     */
    static Collector createQueryCollector(List<QueryCollectorContext> collectors) throws IOException {
        Collector collector = null;
        for (QueryCollectorContext ctx : collectors) {
            collector = ctx.create(collector);
        }
        return collector;
    }

 转换后的tree结构

百分位/基数 原理可以参考文档 

java 加法原理_深入浅出计算机组成原理学习笔记:第十六讲_weixin_39961855的博客-CSDN博客你是不是感到很疑惑,浮点数的近似值究竟是怎么算出来的?浮点数的加法计算又是怎么回事儿?在实践应用中,我们怎么才用好浮点数呢?这一节,我们就一起来看这几个问题一、浮点数的二进制转换1、十进制浮点数9.12、小数的二进制表示是怎么回事3、浮点数其实是用二进制的科学计数法来表示的4、为什么0.3+0.6=0.899999?二、浮点数的加法和精度1、浮点数的加法原理2、比如0.5,表示成浮点数实现这样一个...https://blog.csdn.net/weixin_39961855/article/details/114718101

走近源码:神奇的HyperLogLog - 知乎HyperLogLog是Redis的高级数据结构,是统计基数的利器。 前文我们已经介绍过HyperLogLog的基本用法,如果只求会用,只需要掌握HyperLogLog的三个命令即可,如果想要更进一步了解HyperLogLog的原理以及源码实现,相…https://zhuanlan.zhihu.com/p/58519480

统计去重后的数量 | Elasticsearch: 权威指南 | Elastichttps://www.elastic.co/guide/cn/elasticsearch/guide/current/cardinality.html

 Reids神奇的HyperLoglog解决统计问题 - 我没有三颗心脏 - 博客园 - 结巴练朗读_哔哩哔哩_bilibilihttps://www.cnblogs.com/wmyskxz/p/12396393.htmlReids(4)——神奇的HyperLoglog解决统计问题https://www.bilibili.com/video/BV1SK4y1V7EG?from=search&seid=14672124501694792763&spm_id_from=333.337.0.0

百分位计算 | Elasticsearch: 权威指南 | Elastichttps://www.elastic.co/guide/cn/elasticsearch/guide/current/percentiles.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值