Search code examples
dspace

Search for all objects that are in a date range


Do you know if I can make the following search in DSpace: All objects that have a date metadata field where the date is larger than 2015-12-01 but less than 2016-12-31?

I have already configured the date metadata field as a custom search filter


Solution

  • The query syntax used by DSpace is the Solr query syntax. You don't need to worry about that too much, but you'll need to know how to express a range. For a range in Solr, use [START TO END], swapping in whatever you want for START and END and leave the square brackets/"TO" as is.

    Solr date syntax requires something like this for START and END: 1972-05-20T17:33:18Z -- note the time is in UTC, so you may get slightly unexpected results if you're in a timezone far away from UTC (or calculate what "midnight on December 1st" in your local time is in UTC, then use that in your query).

    Choose "equals" when you add the filter.

    I just tried this with a filter of

    datefield equals [2012-01-01T00:00:00.000Z TO 2013-01-01T00:00:00.000Z]

    in one of my repos and it looks like I got the results I was expecting.