I'm new to Elasticsearch. I'm building a C# service, which will use Elasticsearch to search error logs.
Now I'm trying to make an aggregation, when I try to run the following query in Kibana, it returns 2 aggregations as expected:
GET /live/_search
{
"query": {
"match": {
"Organisation": {
"query": "Schattorie Solutions"
}
}
},
"aggs": {
"ID": {
"terms": {
"field": "ErrorID.keyword"
}
}
}
}
But when I try the following code in C# using the NEST library, I'm getting the same hits. But there is only one aggregation with an ID Key, instead of 2 aggregations with the ErrorID values as the Key...
var recordResponse = await client.SearchAsync(s => s.AllTypes()
.Query(q => q
.Match(mq => mq.Field("Organisation").Query("Schattorie Solutions"))
)
.Aggregations(a => a
.Terms("ID", st => st
.Field(o => o.ErrorID.Suffix("keyword"))
)
)
);
What am I doing wrong?
Edit: I think I got it, the In Kibana I'm looking for "ErrorID.keyword", while the NEST parses JSON which uses "errorID.keyword"...
Is it bas practice to start fields with a capital letter? That's the way modesl are defined in C#, and based on that "LogItem" model the document is created and read...