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(????)
)
)
);
Hmm this could work but Is there any way to tell serializer that it should expect long instead of string,
I don't know where to put that code (accessors get/set of field or anotation)?
And I'am not allowed to change mappings or anything in ES-db (read-only) I just want to specify different way of reading their longs
Hmm that's a problem. I'd open an issue on the .NET client GitHub repo, because you are technically supposed to be able to store and read longs as epoch_millis. There might be some supported way of doing it that I'm not aware of, they'll know better
You might have to fall back to your original approach afterall with a custom DateTime serialiser that deserialises a long to unix millis like this SO question.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.