1.在Java中对应的entity
public class Person {
String name;
int age;
}
2.kibana中的数据
{
"_index": "person_index",
"_type": "person_type",
"_id": "i674x3IBsOhWggMeikEo",
"_score": 1,
"_source": {
"age": 9,
"name": "李四"
}
},
{
"_index": "person_index",
"_type": "person_type",
"_id": "jq74x3IBsOhWggMeikGu",
"_score": 1,
"_source": {
"age": 63,
"name": "侯七"
}
},
{
"_index": "person_index",
"_type": "person_type",
"_id": "ja74x3IBsOhWggMeikGD",
"_score": 1,
"_source": {
"age": 41,
"name": "马六"
}
},
{
"_index": "person_index",
"_type": "person_type",
"_id": "j674x3IBsOhWggMeikHH",
"_score": 1,
"_source": {
"age": 452,
"name": "赵八"
}
},
{
"_index": "person_index",
"_type": "person_type",
"_id": "iq74x3IBsOhWggMeiUGi",
"_score": 1,
"_source": {
"age": 16,
"name": "张三"
}
},
{
"_index": "person_index",
"_type": "person_type",
"_id": "jK74x3IBsOhWggMeikFX",
"_score": 1,
"_source": {
"age": 32,
"name": "王五"
}
},
{
"_index": "person_index",
"_type": "person_type",
"_id": "kK74x3IBsOhWggMeikHU",
"_score": 1,
"_source": {
"age": 32,
"name": "孙九"
}
},
{
"_index": "person_index",
"_type": "person_type",
"_id": "ka74x3IBsOhWggMeikHg",
"_score": 1,
"_source": {
"age": -8,
"name": "钱二麻子"
}
}
3.kibana搜索
可以看出,第一层的hits表示根据请求条件命中的结果的参数,如total,max_score。
hits里的hits就是命中的结果集合,里面是每个结果的index索引,type类型等等,source即对象的值。
4.聚合结果
上面的json搜索条件是先搜出年龄小于60,然后再对搜出的结果进行term分组,类似于sql语句里的group by。
搜索结果里的aggregations下的group下的buckets即为符合条件的聚合结果的集合,即桶。
group是为整个分组结果起的名