Following up on this question here: How to map C# DateTime property to @timestamp field
I initialize the Elastic connection:
ElasticsearchClientSettings settings;
using (settings = new ElasticsearchClientSettings(new Uri($"{configOptions.Url}")))
{
settings = settings
.Authentication(authentication)
.DefaultIndex("filebeat-*-app-logs-*");
Client = new ElasticsearchClient(settings);
Client.ElasticsearchClientSettings.PropertyMappings
.Add(typeof(Audit).GetMember("Timestamp")[0], new PropertyMapping() { Name = "@timestamp" });
}
My query
var searchResponse = await _client.Client.SearchAsync<T>(s => s
.Query(q => q
.MatchPhrase(m => m
.Field("fields.ThermostatId")
.Query("some-guid-here"))));
is able to map data to some of the Properties, namely to the text types Message and Level, all the others stay default initialized.
public class Audit
{
[Keyword(Name = "_id")]
public Guid Id { get; set; }
[Date(Name = "@timestamp")]
public DateTime Timestamp { get; set; }
[Keyword(Name = "level")]
public string Level { get; set; }
[Keyword(Name = "Message")]
public string Message { get; set; }
[Nested]
public ThermostatLog Fields { get; set; }
I tried manually mapping in the config but it doesn't make any difference. The annotiation in the entity class is not proven to be enough.