zoukankan      html  css  js  c++  java
  • Elasticsearch聚合

    聚合分词

    http://localhost:9200/{index}/{type}/_search 

    {
      "aggs": {
      "brands": {
         "terms": { "field": "goods.brandKey" }
       }
     }
    }

    NativeSearchQuery query =  new NativeSearchQueryBuilder()
                    .withIndices("pdm").withTypes("sku")
                    .addAggregation(AggregationBuilders.terms("names").field("name"))
                    .build();
            Aggregations list = template.query(query, new ResultsExtractor<Aggregations>() {
                @Override
                public Aggregations extract(SearchResponse response) {
                    return response.getAggregations();
                }
            });
            for (Aggregation item : list) {

            System.out.println(item.getName());

                StringTerms terms = (StringTerms)item;
                for (Bucket bucket : terms.getBuckets()) {
                    System.out.println(bucket.getKeyAsString());
                }
            }
  • 相关阅读:
    切片 Slice
    表单与v-model
    vue-内置指令
    go单元测试
    go异常处理
    设计模式
    django数据库事务
    go interface衍生的插件化处理
    goroutine
    drf之序列化
  • 原文地址:https://www.cnblogs.com/kingsy/p/7101357.html
Copyright © 2011-2022 走看看