目录
一、聚合索引
1.bucket和metric概念
bucket是一个聚合搜索时的数据分组。
metric就是对一个bucket数据执行的统计分析。
类比sql,bucket类似于group by,metric类似于sum(),count()等聚合语法。
2.操作案例
先新增一些数据:
PUT /cars2
{
"mappings": {
"properties": {
"price": {
"type": "long"
},
"color": {
"type": "keyword"
},
"brand": {
"type": "keyword"
},
"model": {
"type": "keyword"
},
"sold_date": {
"type": "date"
},
"remark":{
"type": "text",
"analyzer": "ik_max_word"