2017-01-12 51 views
0

有了Nest 5,我試圖做一個查詢請求,並就結果使聚合:elasticsearch巢查詢和AGGS在同一時間

在elasticsearch這將是該類型的請求:

POST /index/mappingname/_search 
{ 
    "query": { 
     "match": { 
     "street": "wellington" 
     } 
    }, 
    "aggs" : { 
     "agg_name" : { 
      "terms" : { 
       "field" : "country" 
      } 
     } 
    }, 
    "size" : 0 
} 

回答

0
var response = Client.Search<my_class>(s => s 
    .Query(p => p 
     .Match(m => m 
      .Field(f => f.street) 
      .Query("wellington") 
     ) 
    ) 
    .Size(1000) 
    .Aggregations(a => a 
     .Terms(codeBucket, t => t 
      .Field("country") 
      .Size(100) 
     ) 
    ) 
);