In old ES versions, I was using the _timestamp field but it's been removed and it's now recommended to set the date on the client side. However, I'm surprised to not find any easy way to continue to set it on the server side. Setting the date on the client side is risky for our use case since we don't control the clients (they can be anywhere in the world) and they can put wrong date or in the wrong timezone. Our use case is to record pings from clients and I'd much prefer to set the date using the ES server date/time.
I should have mentioned that I saw this answer in some answer on stackoverflow but I thought it looked a bit complex, hence why I asked the question here. So I gather that there's no simpler way and I'll go in this direction, thanks again!
@dadoonet Sorry, another question related to this. Do you know if this ingest pipeline will overwrite any value set in the timestamp field from your example? Is it possible to say to replace the field value only if it's empty or not set?
pingDate: always set it with an ingest pipeline to be the current server date
firstPingDate: I do some query to find the first ping entry's firstPingDate for a given instance id. If it exists, I set it to that value. If it doesn't exist, I'd like to set it to the current server date. I'd like it to be the same value as the pingDate too.
So 3 questions:
Do I need 2 pipelines?
How can I set firstPingDate in a pipeline, only if not set already?
How can I be sure to use the same value as the pingDate provided by the ES server?
@dadoonet hmm I can't find aJava API to use copy_from, it seems to be missing. This is what I'm trying:
client.ingest().putPipeline(b0 -> b0
.description("Set pingDate to be the server date/time and fill firstPingDate if empty")
.processors(b1 -> b1
.set(b2 -> b2
.set(b3 -> b3
BTW the second set() isn't correct syntactically. How do I setup 2 "set" processors using the java API?