I use java.sql.Timestamp
2014-12-27 00:00:00
and ElasticSearch saves it as 1419634800000
"EventDateLocal" : {
"type" : "long"
},
and I want to read it in C# (via NEST) in DateTime
I tried
[Date(NumericResolution = NumericResolutionUnit.Milliseconds)] ?????
public DateTime? EventDateLocal { get; set; }
What should I put in annotation to get this effect automatically (long + unix => EventDate) :
foreach (var e in request.Documents)
{
var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
var date = start.AddMilliseconds(e.EventDateLocal.Value).ToLocalTime();
}
My NEST configuration is:
var client = new ElasticClient(new ConnectionSettings(new Uri(url))
.DefaultIndex(index)
.DefaultTypeNameInferrer(t => type)
);
If not with annotation is it possible somehow to tell NEST about long saved?
client.Map<Event>(m => m
.AutoMap()
.Properties(ps => ps
.Date(e => e
.Name("EventDateLocal")
.Format(????)
)
)
);