Elastic Date field Retrieval Issue

Is it possible to have custom format for date field store and retrieval so that both the way elastic and java api level will be uniform date.

Now we are facing date field binding to application object date property.
As Elastic Date Format Will joda
application date will be java util date.

Not sure I understand but may be date ingest processor is what you want.

Is there any way to specify or inform elastic to return date in dd-mm-yyyy hh:mm:dd format java.util.date format

With which API?

Java elastic api.

Which API of the Java API?

  • When you do a GET index/type/id?
  • When you do a _search?
    • In the resultset in _source?
    • In the result of aggregations?
  • ...

In Any of the java elastic api Like Get.
the resultant hits field i wanted date filed as custom formatted like dd:mm:yy hh:mm:ss

You will get back what you sent.
Elasticsearch just reads the _source field which contains your json document as is.


There is any option to store date field in specific format.

I think you did not understand what I said.

If you send a date like:

  "date": "10/01/2017"

You will get it back as:

  "date": "10/01/2017"

If you send it as:

  "date": "2017-01-10"

You will get it bas as:

  "date": "2017-01-10"

So it's up to you to send it in the format you expect to find it later.

But always it is stored and retrieved as dd-mm-yyThh:mm:ss

Why do you send it as dd-mm-yyThh:mm:ss?

Hi ,
We are using the logstash jdbc input. i also specified the date format to custom format. but still in elastic stored as dd-mm-yyThh:mm:ss this format. and also i mentioned the date field mapping in elasticsearch as
field : trn_date
format : dd:mm:yy
this format will not used to convert the incoming date data?

The format is used to parse what you sent as a String to a Date object.
Then what is "stored" in the _source is what you sent in the original format.
Elasticsearch does not modify the _source field (unless you are using node ingest feature).

We are using the logstash jdbc input.

That's a new information.
So probably that's how logstash is reading the data from the database. But I'd ask this in #logstash forum instead.

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