2016-08-20 101 views

回答

1

你應該這樣做有terms聚集與min_doc_count: 2這樣

{ 
    "size": 0, 
    "aggs": { 
    "countries": { 
     "terms": { 
     "field": "countryName" 
     }, 
     "aggs": { 
     "ids": { 
      "terms": { 
      "field": "countryId", 
      "min_doc_count": 2 
      } 
     } 
     } 
    } 
    } 
} 

注意,countryName字段應該not_analyzed爲了這個工作,或者countryName場是multi-fieldnot_analyzed部分。

+0

我有一個計數(distinct(countryId))函數,它似乎需要管道agge有過濾器計數 –

+0

countryId和countryName之間有1:1的關係嗎?所以'count(distinct(countryId))== count(distinct(countryName))'對不對? – Val

+0

我的數據計數(distinct(countryId))!= count(distinct(countryName)),所以也許使用min_doc_count是不正確的 –