在elasticsearch上仅聚合出现在两个索引中的值,可以通过使用elasticsearch的聚合功能和索引的交集操作来实现。
具体步骤如下:
POST /_search
{
"size": 0,
"aggs": {
"field_aggregation": {
"terms": {
"field": "your_field",
"size": 10
}
}
},
"query": {
"bool": {
"filter": [
{
"terms": {
"_index": ["index1", "index2"]
}
}
]
}
}
}
上述查询中,your_field
是需要聚合的字段名,index1
和index2
是需要聚合的两个索引名。通过terms
聚合操作可以按照字段值进行聚合,并使用size
参数限制返回的聚合结果数量。
推荐的腾讯云相关产品:腾讯云ES(Elasticsearch Service)
腾讯云ES是基于开源的Elasticsearch和Kibana构建的托管式云搜索服务,提供了稳定可靠的Elasticsearch集群,支持快速构建和部署搜索引擎、日志分析、数据分析等应用场景。
产品介绍链接地址:https://cloud.tencent.com/product/es
领取专属 10元无门槛券
手把手带您无忧上云