Mapping elastic query response to POCOs in NEST

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
                Client = new ElasticsearchClient(settings);

                    .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

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; }

        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.

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