lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shalin Shekhar Mangar <shalinman...@gmail.com>
Subject Re: Storing MYSQL DATETIME field in solr as String
Date Tue, 17 Dec 2013 04:21:29 GMT
I'm sorry. I thought you wanted to parse a date stored as string into
a java.util.Date. Clearly, you are trying to go the other way round.

There's nothing in DIH which will convert a mysql date to a string in
specific format. You will need to write a custom transformer either in
javascript or in java to do this.

http://wiki.apache.org/solr/DIHCustomTransformer
http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer

On Mon, Dec 16, 2013 at 1:34 PM, manju16832003 <manju16832003@gmail.com> wrote:
> 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.



-- 
Regards,
Shalin Shekhar Mangar.

Mime
View raw message