Terms 按字段的值进行分类,并计算出doc_count,

bucket聚合 类似于 group by

常用统计 分类并出现频率高的,并进一步挖出,计算出想要的数据。

参考资料

    https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html    

1.批量插入数据

   curl -XPOST 127.0.0.1:9200/cars/transactions/_bulk --data-binary @cars.json   

{ "index": {}}
{ "price" : 10000, "color" : "red", "make" : "honda", "sold" : "2014-10-28" }
{ "index": {}}
{ "price" : 20000, "color" : "red", "make" : "honda", "sold" : "2014-11-05" }
{ "index": {}}
{ "price" : 30000, "color" : "green", "make" : "ford", "sold" : "2014-05-18" }
{ "index": {}}
{ "price" : 15000, "color" : "blue", "make" : "toyota", "sold" : "2014-07-02" }
{ "index": {}}
{ "price" : 12000, "color" : "green", "make" : "toyota", "sold" : "2014-08-19" }
{ "index": {}}
{ "price" : 20000, "color" : "red", "make" : "honda", "sold" : "2014-11-05" }
{ "index": {}}
{ "price" : 80000, "color" : "red", "make" : "bmw", "sold" : "2014-01-01" }
{ "index": {}}
{ "price" : 25000, "color" : "blue", "make" : "ford", "sold" : "2014-02-12" }
View Code

相关文章:

  • 2021-06-05
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-01-05
  • 2021-08-15
猜你喜欢
  • 2021-11-01
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2021-11-20
相关资源
相似解决方案