peviitor-ro / solr

solr for peviitor.ro
1 stars 1 forks source link

keep data in SOLR #29

Open sebiboga opened 5 months ago

sebiboga commented 5 months ago

add field to save DATE of posting in Apache SOLR In Apache Solr, you can store dates in a field of type solr.DatePointField or solr.TrieDateField (deprecated as of Solr 7.0.0). The format for this field is a restricted subset of the canonical representation of dateTime in the XML Schema specification – a format compatible with ISO-8601.

Here is an example: 2006-11-13T00:00:00Z

Here's how you store datePosted:

In your Solr schema (schema.xml), define a field to hold the date. For example:

xml

When you index documents, use the ISO-8601 combined date and time format in UTC:

json

{ "id": "job1", "datePosted": "2020-12-31T00:00:00Z" } Remember to replace "2020-12-31T00:00:00Z" with your actual date.

You can also use Solr's built-in NOW function to automatically use the current time whenever you add a document to the index:

json

{ "id": "job1", "datePosted": "NOW" } After adding this field, you'll be able to run queries that return documents based on the datePosted field.