Elastic search considers date field send by java service as string

Hi I have created a java service and i am indexing the response into elasticseaarch i am sending a date value but elasticsearch considers it as string. Code is already deployed in production. How to change the incoming field i should inform elastic search to consider it as a datefield?

          "producercode" : "B39882",
          "send" : "Y",
          "open" : "",
          "timestamp" : "Mon Oct 12 07:29:59 PDT 2020"

Is der any possibility of creating pipeline if index name contains prefix like this "notification-service-track-" It should convert this and should index this as a datefield.

Note: We are creating a date based index so by using index API java we are creating index hence index mapping is created by elasticsearch only

Create mappings and let elastic know it is a date.

It is a date based index every day index name change dynamically. So instead of using new Date() directly i have converted the dateformat to "yyyy-MM-dd'T'HH:mm:ssZ" in my java service now elasticsearch considers it as a date field but this leads to code change.

    SimpleDateFormat elkTimestamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    String elkTime = elkTimestamp.format(new Date());

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