Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to store date in S.d.f(08/20/2019) instead of timestamp in elastics
Hi All
I created custom entity using elasticsearch module in liferay 7.1. 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
I created custom entity using elasticsearch module in liferay 7.1. 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
Sure, just store as text in the doc and format it as you like in your custom indexing code.
Hi David
Thanks for your reply.
I followed your suggestion and tested the functionality but it stored data in 20190420442288 (yyyyMMddHHmmss) only. But i need to store data in 04/20/2019 format. See below mapping of date field in index.
In my Index date field mapping like this below
"modified" : {
"type" : "date",
"store" : true,
"format" : "yyyyMMddHHmmss"
},
I need to update the above date field format in mapping like this below
"modified" : {
"type" : "date",
"store" : true,
"format" : "MM/dd/yyyy"
},
Please give any suggestion for this requirement.
Thanks
Lokesh
Thanks for your reply.
I followed your suggestion and tested the functionality but it stored data in 20190420442288 (yyyyMMddHHmmss) only. But i need to store data in 04/20/2019 format. See below mapping of date field in index.
In my Index date field mapping like this below
"modified" : {
"type" : "date",
"store" : true,
"format" : "yyyyMMddHHmmss"
},
I need to update the above date field format in mapping like this below
"modified" : {
"type" : "date",
"store" : true,
"format" : "MM/dd/yyyy"
},
Please give any suggestion for this requirement.
Thanks
Lokesh
That was not my suggestion at all. I never said the index should be modified to use a different format.
What I said was that the index field should be text and your custom IndexPostProcessor would itself do the formatting in the way you wanted and set the text field that way.
What I said was that the index field should be text and your custom IndexPostProcessor would itself do the formatting in the way you wanted and set the text field that way.
Hi Lokesh gorrela,
In my opinion, it is better to store all date information as timestamp in Elasticsearch, as you will be able to do operations like sorting or search by date intervals.
If you want to index it with other format, it is better to create a different field, as David said, for example "modified_mmddyyy" and store/retrieve that field instead.
Nevertheless: Why do you want to store dates with that non-timestamp format? If you want to retrieve it from the index and display it somewhere, it is better to convert the date before displaying it.
Regards,
Jorge
In my opinion, it is better to store all date information as timestamp in Elasticsearch, as you will be able to do operations like sorting or search by date intervals.
If you want to index it with other format, it is better to create a different field, as David said, for example "modified_mmddyyy" and store/retrieve that field instead.
Nevertheless: Why do you want to store dates with that non-timestamp format? If you want to retrieve it from the index and display it somewhere, it is better to convert the date before displaying it.
Regards,
Jorge