Kibana vs NEST, not getting same result?

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...

NEST by default camelcases POCO property names when serializing them to JSON. This was an early design decision within the client that has continued to be the default.

You can change how NEST serializes property names through .DefaultFieldNameInferrer(Func<string, string>) on ConnectionSettings

Well, I've refactored my code for now... But thanks for the advise, I'll look into that later...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.