是否有可能获得的不仅仅是使用Elasticsearch聚合桶的密钥?例如,如果我要获得国家/地区,我可以按以下方式获取密钥:
"aggregations": {
"countries": {
"buckets": [
{
"key": "china",
"doc_count": 1
},
{
"key": "italy",
"doc_count": 1
},
{
"key": "japan",
"doc_count": 1
},
{
"key": "united-kingdom",
"doc_count": 1
}
]
}
}
但我还想获得一些相关数据,例如国名不是slu ::(例如中国,意大利,日本,英国)。
现在映射就像这样
PUT tester/listing/_mapping
{
"properties": {
"title": {
"type": "string"
},
"countries": {
"type": "string",
"index": "not_analyzed",
"doc_values": true
}
}
}
记录的索引如下:
POST tester/listing/1
{
"title": "First Listing",
"countries": ["spain", "italy"]
}
POST tester/listing/2
{
"title": "Second Listing",
"countries": ["japan", "united-kingdom"]
}