1
votes

Can we use Solr _ version _ field as a timestamp/version so that we can query the latest documents from a particular _ version _ /timestamp?

My requirement is to periodically (daily) retrieve new documents from my solr index. But there is no data/timestamp field to use as a filter to query latest documents.

Can I use _ version _ field for this in Solr ? (As it's an automatically indexed field for every document)

1

1 Answers

1
votes

You can index additional field to keep the index date for the documents.

<field name="indexeddate" type="date" default="NOW" indexed="true" stored="true"/>

Even, you do not need to index this field, as this field comes with default value "NOW". So whenever you index the document, indexeddate field will also be indexed with the recent date. Then you can perform solr date range query on this field to retrieve latest documents.

For more on Solr dates format and range queries https://lucene.apache.org/solr/guide/6_6/working-with-dates.html