I have an Elasticsearch database and I have an index test
Here the schema:
PUT test
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"channel" : {
"properties" : {
"id" : { "type" : "integer" },
"name" : { "type" : "string" }
}
},
"segment" : {
"properties" : {
"groupid" : { "type" : "text", "fielddata": true },
"instrName" : { "type" : "text", "fielddata": true },
"channelList" : { "type" : "object" }
}
}
}
}
I'd like to convert this query into C# NEST code:
GET /test/segment/_search
{
"aggs": {
"agg": {
"terms": {
"field": "instrName"
},
"aggs": {
"agg2": {
"terms": {
"field": "groupid"
}
}
}
}
}
}
I know how to convert a single aggregation query but not a nested aggregation
EDIT
Here the current code but I get a 500 error from ES
var res = elastic.Search<SegmentRecord>(
s => s.Index(esIndex).Aggregations(a => a.Terms("instrName", x => x.Aggregations(w => w.Terms("groupid", sel => sel)))));