这是我在Elasticsearch中索引的映射。如何使用Java中的Rest高级客户端在字段名称上汇总转销商?
PUT /index
{
"mappings": {
"properties" : {
"resellers" : {
"type" : "nested",
"properties" : {
"name" : { "type" : "text" },
"price" : { "type" : "double" }
}
}
}
}
}
示例文档:
[{"reseller1":{"name":"name1", "price":100}},
{"reseller1":{"name":"name2", "price":200},
{"reseller1":{"name":"name3", "price":100}},
{"reseller1":{"name":"name4", "price":300}}]
如果我想基于价格进行汇总,那么我希望输出如下所示:
"price":100 2 docs
"price":200 1 docs
"price":300 1 docs