Search code examples
solrfaceted-search

Error on a Faceted Date Range Query for Solr


I'm trying to get a list of year facets e.g.

2000 (3)
2001 (27)
2002 (15)
...

I have a local instance of Solr 3.6 running from the Solr wiki tutorial http://lucene.apache.org/solr/api/doc-files/tutorial.html

I tried the following query:

http://localhost:8983/solr/select/?q=*:*
&version=2.2
&start=0
&rows=10
&indent=on
&facet=true
&facet.range=manufacturedate_dt
&facet.range.gap=+1YEAR
&f.manufacturedate_dt.facet.range.start=/NOW/YEAR-5YEARS
&f.manufacturedate_dt.facet.range.end=/NOW

I'm using range because of the warning here http://wiki.apache.org/solr/SimpleFacetParameters#rangefaceting

"NOTE: as of Solr3.1 Date Faceting has been deprecated in favor of the more general Range Faceting described below. The response structure is slightly different, but the functionality is equivalent (except that it supports numeric fields as well as dates)"

The error I get is:

HTTP ERROR 400

Problem accessing /solr/select/. Reason:

    Can't parse value /NOW/YEAR-5YEARS for field: manufacturedate_dt

I tried replacing + with %2B as mentioned in another StackOverflow question. Any ideas would be awesome.


Solution

  • Get rid of the slashes in front of NOW -- so facet.range.end=NOW/YEAR.....