Directly after I sent my email, I tested using two different field names, 
instead of the same field name for both range facets. And then it worked.

So, it seems there is a bug that can't handle multiple range facets for the 
same field name. A workaround is to use a copyfield to another field, and do 
the second range facet for that second field name. But surely this is a bug in 
Solr, right? Maybe it has already been reported, but I couldn't find anything.

/Jimi

> -----Ursprungligt meddelande-----
> Från: jimi.hulleg...@svensktnaringsliv.se
> [mailto:jimi.hulleg...@svensktnaringsliv.se]
> Skickat: den 12 november 2013 15:08
> Till: solr-user@lucene.apache.org
> Ämne: Date range faceting with various gap sizes?
> 
> Hi,
> 
> I'm experimenting with date range faceting, and would like to use different
> gaps depending on how old the date is. But I am not sure on how to do that.
> 
> This is what I have tried, using the java API Solrj 4.0.0 and Solr 4.1.0:
> 
> solrQuery.addDateRangeFacet("scheduledate_start_tdate", date1, date2,
> "+1YEAR"); solrQuery.addDateRangeFacet("scheduledate_start_tdate",
> date3, date4, "+1MONTH"); solrQuery.setFacetMinCount(1);
> 
> The first date interval is between 1990 and 2011, and the second interval is
> 2011 to 2014.
> 
> This results in this URL:
> 
> http://localhost:8080/solr/select?q=*:*&facet.range=scheduledate_start_td
> ate&facet.range=scheduledate_start_tdate&f.scheduledate_start_tdate.fac
> et.range.start=1990-01-
> 01T11%3A00%3A00.000Z&f.scheduledate_start_tdate.facet.range.start=2011
> -01-
> 01T11%3A00%3A00.000Z&f.scheduledate_start_tdate.facet.range.end=2011
> -01-
> 01T10%3A59%3A59.999Z&f.scheduledate_start_tdate.facet.range.end=2014
> -01-
> 01T11%3A00%3A00.000Z&f.scheduledate_start_tdate.facet.range.gap=%2B1
> YEAR&f.scheduledate_start_tdate.facet.range.gap=%2B1MONTH&facet=tru
> e&facet.mincount=1&wt=xml&indent=true
> 
> And the response contains this:
> 
> <lst name="facet_ranges">
>             <lst name="scheduledate_start_tdate">
>                          <lst name="counts">
>                                      <int 
> name="2006-01-01T11:00:00Z">207</int>
>                                      <int 
> name="2007-01-01T11:00:00Z">818</int>
>                                      <int 
> name="2008-01-01T11:00:00Z">811</int>
>                                      <int 
> name="2009-01-01T11:00:00Z">618</int>
>                                      <int 
> name="2010-01-01T11:00:00Z">612</int>
>                          </lst>
>                          <str name="gap">+1YEAR</str>
>                          <date name="start">1990-01-01T11:00:00Z</date>
>                          <date name="end">2011-01-01T11:00:00Z</date>
>             </lst>
>             <lst name="scheduledate_start_tdate">
>                          <lst name="counts">
>                                      <int 
> name="2006-01-01T11:00:00Z">207</int>
>                                      <int 
> name="2007-01-01T11:00:00Z">818</int>
>                                      <int 
> name="2008-01-01T11:00:00Z">811</int>
>                                      <int 
> name="2009-01-01T11:00:00Z">618</int>
>                                      <int 
> name="2010-01-01T11:00:00Z">612</int>
>                          </lst>
>                          <str name="gap">+1YEAR</str>
>                          <date name="start">1990-01-01T11:00:00Z</date>
>                          <date name="end">2011-01-01T11:00:00Z</date>
>             </lst>
> </lst>
> 
> Right away I notice that this is incorrect. The second facet range incorrectly
> uses the same gap, start and end-values as the first one. Can someone
> understand why? And is there a way to make this work?
> 
> Regards
> /Jimi

Reply via email to