Mecca
Mecca

Reputation: 659

Solr date field doesn't store the time

I have a datetime field in MySQL that I'm also using in a SOLR index. For some reason, it seems SOLR is loosing the time value and rounds it up to 5AM.

In the database: 2014-09-29 09:01:15

In SOLR: 2014-09-29T05:00:00Z

It happens with all datetime fields, in 2 separate indexes, regardless of how old the record is. Reindex and cleanup is being done regularly.

From schema.xml:

<fieldType name="date" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>

and later on

<field name="gallery_date" type="date" indexed="true"/>

I was thinking is a timezone issue, but I'm not doing any timezone transformations or reformatting. The field is added "as is" into SOLR.

My goal is to get correct sorting at the minute/second level, which doesn't work properly right now. Any ideas?

Thank you

SOLR version 3.6.1

Upvotes: 0

Views: 1281

Answers (2)

Chethan Swaroop
Chethan Swaroop

Reputation: 192

The 5 hrs round up in Solr is probably because of the Type of Solr field selected.

You might have probably used the TrieDateField.

http://lucene.apache.org/solr/6_0_0/solr-core/org/apache/solr/schema/TrieDateField.html

Upvotes: 1

Mecca
Mecca

Reputation: 659

It's related to this bug https://issues.apache.org/jira/browse/SOLR-4978

I had convertType="true" in data-config.xml . As a workaround, I've set it to false.

Upvotes: 1

Related Questions