Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value in a field in the Solr schema can be the current date?

Tags:

java

solr

I'm using Solr and I would like to add a field last_update in the schema.xml where the default value would be the current date when the document is added or updated.

Do you have an idea how can I do this?

Thanks

like image 943
Remy Avatar asked Sep 06 '11 09:09

Remy


People also ask

What is field type in SOLR?

A field type defines the analysis that will occur on a field when documents are indexed or queries are sent to the index. A field type definition can include four types of information: The name of the field type (mandatory). An implementation class name (mandatory).

What are dynamic fields in Solr?

Dynamic fields allow Solr to index fields that you did not explicitly define in your schema. This is useful if you discover you have forgotten to define one or more fields. Dynamic fields can make your application less brittle by providing some flexibility in the documents you can add to Solr.


1 Answers

It is a supported scenario for DateField. The following should work:

<field name="last_update" type="date" indexed="true" stored="true" default="NOW" />
like image 111
skuro Avatar answered Oct 11 '22 13:10

skuro