How to store date format as Simple date format instead of Timstamp while indexing

In my table in database , date column having 2018-07-09 00:00:00 format date, but while indexing that date, It is stored as timestamp in elasticsearch. How I can store 04-20-2019 (Simple date format) instead of timestamp in elasticsearch.

Anyone knows about this requirement please give reply to me.

Thanks
Lokesh

You need to change what you are sending to elasticsearch if you want to have it in the _source field.

May be describe how you are injecting data and we could propose solutions?

Hi

Thanks for your response.

I passed date value as Mon Jul 15 12:15:59 IST 2019 in this format for indexing a document. After indexed a document it stored date as 20190615182947 this timestamp format. But I want to store date as simple date format(MM-DD-YYYY).

Please give any suggestions for my requirement.

Thanks
Lokesh

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

This is my mapping:

"modified" : {
"type" : "date",
"store" : true,
"format" : "yyyyMMddHHmmss"
},
"modified_sortable" : {
"type" : "long",
"store" : true
},
"mybookName_en_US" : {
"type" : "text",
"store" : true,
"term_vector" : "with_positions_offsets",
"analyzer" : "english"
},
"name" : {
"type" : "text",
"store" : true
},

This is my documents in elastic search:

{"uid":"20100_spellCheckWord_fWUSdV4flcavJZzNWOj4Ew==","companyId":"20100","groupId":"0","spellCheckWord_en_US":"smith","languageId":"en_US","priority":"0.0","type":"spellChecker"}},{"_index":"liferay-20100","_type":"LiferayDocumentType","_id":"com.liferay.docs.guestbook.model.Entry_PORTLET_80202","_score":6.8558645,"_source":{"entryClassPK":"80202","publishDate_sortable":0,"groupId":"20127","priority_sortable":0.0,"publishDate":"19700101053000","guestbookName_en_US":"Main","createDate_sortable":1563190379336,"uid":"com.liferay.docs.guestbook.model.Entry_PORTLET_80202","groupRoleId":"20127-20115","scopeGroupId":"20127","modified":"20190715170259","modified_sortable":1563190379420,"expirationDate_sortable":9223372036854775807,"email":"smith@gmail.com","createDate":"20190715170259","expirationDate":"99950812133000","content_en_US":"H}

In the above document date field is stored as a Timestamp format (19700101053000) . but I need to store date format as (MM/DD/YYYY) instead of Timestamp.

Please give a suggestion for my requirement.

Thanks
Lokesh

This works for me:

DELETE test
PUT test
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date",
        "format": "MM/DD/YYYY"
      }
    }
  }
}
PUT test/_doc/1
{
  "date": "12/26/1971"
}

If you can't make it work, please provide a similar script to show what the problem is.

Hi

Thanks for your reply.

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