elasticsearch 同时嵌套查询和聚合
elasticsearch nest query and aggs at same time
使用 Nest 5,我正在尝试发出查询请求并对结果进行聚合:
在 elasticsearch 中是这种类型的请求:
POST /index/mappingname/_search
{
"query": {
"match": {
"street": "wellington"
}
},
"aggs" : {
"agg_name" : {
"terms" : {
"field" : "country"
}
}
},
"size" : 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)
)
)
);
使用 Nest 5,我正在尝试发出查询请求并对结果进行聚合:
在 elasticsearch 中是这种类型的请求:
POST /index/mappingname/_search
{
"query": {
"match": {
"street": "wellington"
}
},
"aggs" : {
"agg_name" : {
"terms" : {
"field" : "country"
}
}
},
"size" : 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)
)
)
);