Re: Date range faceting with various gap sizes?

2013-11-15 Thread jimi.hullegard
 Chris Hostetter wrote:

 You can see that in the resulting URL you got the params are duplicated -- the
 problem is that when expressed this way, Solr doesn't know when the
 different values of the start/end/gap params should be applied -- it just
 loops over each of the facet.range fields (in your case: the same field
 twice) and then looks for a coorisponding start/end/gap value and finds the
 first one since there are duplicates.

OK, that explains it. I thought that it would match the params, so that it 
would match the first parameter facet.range=scheduledate_start_tdate with the 
first parameter 
f.scheduledate_start_tdate.facet.range.start=1990-01-01T11:00:00.000Z, the 
second parameter facet.range=scheduledate_start_tdate with the second 
parameter 
f.scheduledate_start_tdate.facet.range.start=2011-01-01T11:00:00.000Z and so 
on.

 what you want to do can be accomplished (as of Solr 4.3 - see SOLR-1351) by
 using local params in the facet.range (or facet.date) params...
 
 http://localhost:8983/solr/select?q=*:*rows=0facet=truefacet.range={!
 facet.range.start=NOW/MONTH%20facet.range.end=NOW/MONTH%2B1M
 ONTH%20facet.range.gap=%2B1DAY}manufacturedate_dtfacet.range={!fa
 cet.range.start=NOW/MONTH%20facet.range.end=NOW/MONTH%2B1MO
 NTH%20facet.range.gap=%2B5DAY}manufacturedate_dt

Thanks for this info. I'm not sure it is easy to upgrade Solr for us though, 
since it is more or less integrated into the CMS we use.

But I actually realized that for this particular case, we don't need different 
gap sizes. We can use the before and after metadata instead.
 
Regards
/Jimi




Re: Date range faceting with various gap sizes?

2013-11-14 Thread Chris Hostetter


: 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.

What you are trying to do is possible, but the SolrJ helper methods you 
are using predates the ability and doesn't currently work the way it 
should...

: solrQuery.addDateRangeFacet(scheduledate_start_tdate, date1, date2, 
+1YEAR);
: solrQuery.addDateRangeFacet(scheduledate_start_tdate, date3, date4, 
+1MONTH);

the addDateRangeFacet method you are calling is just syntactic sugar for 
the add(String,String) method called on the various params: facet.range, 
facet.range.start, etc

You can see that in the resulting URL you got the params are duplicated -- 
the problem is that when expressed this way, Solr doesn't know when the 
different values of the start/end/gap params should be applied -- it just 
loops over each of the facet.range fields (in your case: the same field 
twice) and then looks for a coorisponding start/end/gap value and finds 
the first one since there are duplicates.

what you want to do can be accomplished (as of Solr 4.3 - see SOLR-1351) 
by using local params in the facet.range (or facet.date) params...

http://localhost:8983/solr/select?q=*:*rows=0facet=truefacet.range={!facet.range.start=NOW/MONTH%20facet.range.end=NOW/MONTH%2B1MONTH%20facet.range.gap=%2B1DAY}manufacturedate_dtfacet.range={!facet.range.start=NOW/MONTH%20facet.range.end=NOW/MONTH%2B1MONTH%20facet.range.gap=%2B5DAY}manufacturedate_dt

I've opened a new issue to track fixing these sugar methods -- patches 
to improve this would certainly be welcome, but note that it regardless of 
hte SolrJ behavior you'll need to upgrade to at least Solr 4.3 for the 
server side piece to work, and you cna work arround hte client side 
behavior by calling add(String,String) directly.

https://issues.apache.org/jira/browse/SOLR-5443

-Hoss


Date range faceting with various gap sizes?

2013-11-12 Thread jimi.hullegard
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_tdatefacet.range=scheduledate_start_tdatef.scheduledate_start_tdate.facet.range.start=1990-01-01T11%3A00%3A00.000Zf.scheduledate_start_tdate.facet.range.start=2011-01-01T11%3A00%3A00.000Zf.scheduledate_start_tdate.facet.range.end=2011-01-01T10%3A59%3A59.999Zf.scheduledate_start_tdate.facet.range.end=2014-01-01T11%3A00%3A00.000Zf.scheduledate_start_tdate.facet.range.gap=%2B1YEARf.scheduledate_start_tdate.facet.range.gap=%2B1MONTHfacet=truefacet.mincount=1wt=xmlindent=true

And the response contains this:

lst name=facet_ranges
lst name=scheduledate_start_tdate
 lst name=counts
 int name=2006-01-01T11:00:00Z207/int
 int name=2007-01-01T11:00:00Z818/int
 int name=2008-01-01T11:00:00Z811/int
 int name=2009-01-01T11:00:00Z618/int
 int name=2010-01-01T11:00:00Z612/int
 /lst
 str name=gap+1YEAR/str
 date name=start1990-01-01T11:00:00Z/date
 date name=end2011-01-01T11:00:00Z/date
/lst
lst name=scheduledate_start_tdate
 lst name=counts
 int name=2006-01-01T11:00:00Z207/int
 int name=2007-01-01T11:00:00Z818/int
 int name=2008-01-01T11:00:00Z811/int
 int name=2009-01-01T11:00:00Z618/int
 int name=2010-01-01T11:00:00Z612/int
 /lst
 str name=gap+1YEAR/str
 date name=start1990-01-01T11:00:00Z/date
 date name=end2011-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


SV: Date range faceting with various gap sizes?

2013-11-12 Thread jimi.hullegard
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
 atefacet.range=scheduledate_start_tdatef.scheduledate_start_tdate.fac
 et.range.start=1990-01-
 01T11%3A00%3A00.000Zf.scheduledate_start_tdate.facet.range.start=2011
 -01-
 01T11%3A00%3A00.000Zf.scheduledate_start_tdate.facet.range.end=2011
 -01-
 01T10%3A59%3A59.999Zf.scheduledate_start_tdate.facet.range.end=2014
 -01-
 01T11%3A00%3A00.000Zf.scheduledate_start_tdate.facet.range.gap=%2B1
 YEARf.scheduledate_start_tdate.facet.range.gap=%2B1MONTHfacet=tru
 efacet.mincount=1wt=xmlindent=true
 
 And the response contains this:
 
 lst name=facet_ranges
 lst name=scheduledate_start_tdate
  lst name=counts
  int 
 name=2006-01-01T11:00:00Z207/int
  int 
 name=2007-01-01T11:00:00Z818/int
  int 
 name=2008-01-01T11:00:00Z811/int
  int 
 name=2009-01-01T11:00:00Z618/int
  int 
 name=2010-01-01T11:00:00Z612/int
  /lst
  str name=gap+1YEAR/str
  date name=start1990-01-01T11:00:00Z/date
  date name=end2011-01-01T11:00:00Z/date
 /lst
 lst name=scheduledate_start_tdate
  lst name=counts
  int 
 name=2006-01-01T11:00:00Z207/int
  int 
 name=2007-01-01T11:00:00Z818/int
  int 
 name=2008-01-01T11:00:00Z811/int
  int 
 name=2009-01-01T11:00:00Z618/int
  int 
 name=2010-01-01T11:00:00Z612/int
  /lst
  str name=gap+1YEAR/str
  date name=start1990-01-01T11:00:00Z/date
  date name=end2011-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