Yuval Netanel
Yuval Netanel

Reputation: 21

How to get recored creation time in solr?

I'm using DataImportHandler to index data from Postgres

I would like to get the record creation time so I could compare it to the actual object creation time later

These records are being updated (by id), so adding "NOW" field won't do the trick

Upvotes: 1

Views: 1273

Answers (1)

Yuval Netanel
Yuval Netanel

Reputation: 21

This is how I did it eventually:

1.Use multiValued

schema.xml:

<field name="creation_time"  type="date" indexed="false"  stored="true" required="false" multiValued="true" />

2. Add FirstFieldValueUpdateProcessorFactory to the update process chain, which will keep only the first value

solrconfig.xml under updateRequestProcessorChain:

<processor class="solr.FirstFieldValueUpdateProcessorFactory">
  <str name="fieldName">creation_time</str>
</processor>

3. When indexing use solr 4.0 atomic update "add" on this field:

{"creation_time": {"add":"2012-03-06T15:02:45.017Z"}}

The solution is taken from here:

https://issues.apache.org/jira/browse/SOLR-4468

Upvotes: 1

Related Questions