zoukankan      html  css  js  c++  java
  • es按时间段统计总数

    SearchRequestBuilder searchRequestBuilder = client.prepareSearch().setIndices("ishangzu-service-contract-log-2017.07.10")

    .setTypes("service-contract-log").setSearchType(SearchType.COUNT);

    DateHistogramBuilder agg = AggregationBuilders.dateHistogram("by_time").field("@timestamp").interval(60000);

    //日期过滤

    BoolQueryBuilder bool=QueryBuilders.boolQuery();

    BoolQueryBuilder dateQuery=QueryBuilders.boolQuery();

    dateQuery.must(QueryBuilders.rangeQuery("@timestamp").from("1499616000000"));

    dateQuery.must(QueryBuilders.rangeQuery("@timestamp").to("1499688000000"));

    bool.must(dateQuery);

    //filter agg

    FilterAggregationBuilder filter=AggregationBuilders.filter("filter").filter(dateQuery).subAggregation(agg);

    searchRequestBuilder.addAggregation(filter);

    System.out.println(searchRequestBuilder);

    //统计

    SearchResponse searchResponse=null;

    try {

    searchResponse = searchRequestBuilder.get();

    } catch (Exception e) {

    e.printStackTrace();

    }

    System.out.println(searchResponse);

  • 相关阅读:
    docker-machine create ,,,
    docker run with zabbix3.0
    mysql 官网
    取模性质
    欧涛最短路【记录最短路径】
    P4568 飞行路线【分层图最短路】
    CCF201403 无线网络【限制型最短路】
    POJ2449 【第k短路/A*】
    Feeding Time 【bfs求最大连通块】
    printf特殊用法
  • 原文地址:https://www.cnblogs.com/lovlos/p/7150873.html
Copyright © 2011-2022 走看看