You can use filter query and form the date as follows when a user enters just 
the year or year and month:

If just the year (1885) was entered -> date:[1885-01-01T00:00:00Z TO 
1886-01-01T00:00:00Z]
If just the year and month (1885-06) were entered -> date:[1885-06-01T00:00:00Z 
TO 1885-07-01T00:00:00Z]

Alternatively use DateRangeField as described at the bottom in the following 
webpage: 

https://cwiki.apache.org/confluence/display/solr/Working+with+Dates

:Sagar

-----Original Message-----
From: Scott Derrick [mailto:sc...@tnstaafl.net] 
Sent: Tuesday, August 11, 2015 3:02 PM
To: solr-user@lucene.apache.org
Subject: Using the date field for searching

If I query date:1885

I get an error

org.apache.solr.common.SolrException: Invalid Date String:'1885'

If I query date:1885*

I get no results.

and yet there are numerous docs with a year of 1885 in the date string, like so

<arr name="date"><date>1885-02-08T00:00:00Z</date></arr>

if I query date:1885-02-08T00:00:00Z

I get 9 results??

Do the users really have to specify a full xml compliant date string to use the 
date: field for searching?

thanks,

Scott

Reply via email to