![](/img/trans.png)
[英]Elasticsearch Query - How to aggregate timestamps and filter by term?
[英]elasticsearch - how to aggregate and filter by multiple rows
您應按所需貨幣過濾查詢,並用術語匯總對其進行匯總。
棘手的部分是迫使Elasticsearch獲得所有可能的國家。 這可以通過在聚合中使用size = 0參數來完成
currencies_criteria = [1,2]
elasticsearch_query = {
"query": {
"filtered": {
"filter": {
"bool": {
"must" : [
{
"term": {"currency" : currencies_criteria}
}
]
}
}
}
},
"aggs" : {
"country_count" : {
"terms" : {
"field" : "country",
#https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts
"size" : 0
}
}
}
}
您可以在此筆記本中看到此答案的示例執行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.