How to change date format in solr yyyy-mm-ddThh:mm:ssZ into " yyyy-mm-dd"?
Asked Answered
U

3

5

I want to change default date format in solr "yyyy-mm-ddThh:mm:ssZ" into "yyyy-mm-dd". To change date format what is the file should change inside solr folder? Where and what is the configuration file which can configure date foramt?

Ungenerous answered 23/4, 2014 at 4:52 Comment(0)
H
8

The date format used is a restricted form of the canonical representation of dateTime in the XML Schema specification. You can not change the solr default date format.

And schema.xml is the file to configure the date field.

Example:

<field name="Date" datetimeformat="YYYY-MM-DD'T'HH:mm:sss'Z'" 
indexed="true" multivalued="false" stored='true' type="date"> </field>
Honora answered 23/4, 2014 at 5:48 Comment(2)
Your answer helps me lot and we can not change default date format to correctly index date Mysql database should have "DateTime"/Timestamp data type for date column.Ungenerous
You probably don't want capital YYYY because that is the week-year, you want lowercase yyyyBibliogony
M
0

To do this while using javascript I used the split method.

var newdate = olddate.split("T")[0];
output += newdate;
return output;
Mayberry answered 19/3, 2019 at 16:7 Comment(0)
G
0

Two options

  1. you can perhaps make your XSLT transform the date if importing from XML

  2. use DataImportHandler and DateTransformer: http://wiki.apache.org/solr/DataImportHandler#DateFormatTransformer

Girovard answered 12/6, 2019 at 23:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.