This question is related to: Solr - count documents in the range of two date fields
In my schema, I have a DateRangeField called dateRange
like mentioned in the other question.
I can do range facet queries on this field using this:
/select
?wt=json
&q=*:*
&facet=true
&facet.range=dateRange
&facet.range.start=NOW/DAY-30DAYS
&facet.range.end=NOW/DAY%2B1DAYS
&facet.range.gap=%2B1DAY
&rows=0
Now I have another string multi-valued field called interests
on which I want to further bucket the date facets. Here is an example document:
{
"id": "3",
"dateRange": "[2017-12-08T00:00:00Z TO 2017-12-10T03:45:55.567Z]",
"interests": ["hockey", "soccer"]
}
So I want to combine pivot faceting with the range faceting query I am doing above. Is there a way to do this?
As an alternative, I looked at going the JSON faceting route. But I can't get even the date range query to work. Here is the query:
curl http://localhost:8983/solr/gs2/query -d 'q=*:*&rows=0&
json.facet={
dates_f : {
type : range,
field : dateRange,
start : "2017-12-01T00:00:00Z",
end : "2017-12-14T00:00:00Z",
gap : "%2B1DAY"
}
}
'
and this throws the following error:
{
"responseHeader":{
"zkConnected":true,
"status":400,
"QTime":55,
"params":{
"q":"*:*",
"json.facet":"{ \n dates_f : { \n type : range, \n field : dateRange, \n start : \"2017-12-01T00:00:00Z\",\n end : \"2017-12-14T00:00:00Z\", \n gap : \"+1DAY\"\n } \n} \n",
"rows":"0"}},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException",
"error-class","org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException",
"root-error-class","org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException"],
"msg":"Error from server at http://xxx.xx.xx.xx:7574/solr/gs2_shard2_replica1: Unable to range facet on field:dateRange{type=date_range,properties=indexed,stored,omitTermFreqAndPositions,useDocValuesAsStored}",
"code":400}}
Not sure why Solr cannot range facet on a DateRangeField.