• 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());
                }
            }
  • 相关阅读:
    ASCII,Unicode,UTF
    C#值类型和引用类型2
    C#中使用Foreach
    CSS基础(2)
    CSS基础
    HTML基础
    MySQL高级
    MySQL和Python交互案例练习(2)
    MySQL和Python交互案例练习(1)
    外键SQL语句的编写
  • 原文地址:https://www.cnblogs.com/kingsy/p/7101357.html
Copyright © 2020-2023  润新知