OK here are the scenarios I tried.

*Scenario - 1: *

dih.xml (aka data-config.xml)

<entity dataSource="solr" name="listing" query="..."
transformer="DateFormatTransformer">

<field name=&quot;publish_date&quot; column=&quot;publish_date&quot;
xpath=&quot;/RDF/item/date&quot;
dateTimeFormat=&quot;&lt;b>yyyy-MM-dd'T'HH:mm:ss*" locale="en"/>

schema.xml
<field name="publish_date" type="date" indexed="true" stored="true" 
multiValued="false" default="NOW" />

It does not work. Throws an following exception 
WARN  org.apache.solr.handler.dataimport.DateFormatTransformer  – Could not
parse a Date field
java.text.ParseException: Unparseable date: "2013-12-05 15:40:03.0"

*Scenario - 2*
dih.xml (aka data-config.xml)

<entity dataSource="solr" name="listing" query="..."
transformer="DateFormatTransformer">

<field name=&quot;publish_date&quot; column=&quot;publish_date&quot;
xpath=&quot;/RDF/item/date&quot; dateTimeFormat=&quot;&lt;b>yyyy-MM-dd
HH:mm:ss*" locale="en"/> 

schema.xml
<field name="publish_date" type="date" indexed="true" stored="true" 
multiValued="false" default="NOW" />

Output is 
<date name="publish_date">2012-12-05T07:38:27Z</date>

*Scenario - 3*
dih.xml (aka data-config.xml)

<entity dataSource="solr" name="listing" query="..."
transformer="DateFormatTransformer">

<field name=&quot;publish_date&quot; column=&quot;publish_date&quot;
xpath=&quot;/RDF/item/date&quot; dateTimeFormat=&quot;&lt;b>yyyy-MM-dd
HH:mm:ss*" locale="en"/> 

schema.xml
<field name="publish_date" type="string" indexed="true" stored="true" 
multiValued="false" default="NOW" /> 

Output is 
  <str name="publish_date">Thu Dec 05 15:38:27 MYT 2013</str>

My expectation was *2012-12-05 07:38:27* (MySQL DateTime format)



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Storing-MYSQL-DATETIME-field-in-solr-as-String-tp4106836p4106854.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to