[Solr 4] Data grouping on weeks

2013-11-11 Thread Jamshaid Ashraf
Hi,

I'm new with solr and wanted to group data on weeks, is there any built-in
date round function so I give date to this function and it return me the
week of the year.

For example I query to solr against date (01/01/2013) it should return me
(1st week of 2013).

Like I have following documents in solr:

Doc1  CreatedDate: 1/1/2013 Data:ABC
Doc2  CreatedDate: 4/1/2013 Data:ABC
Doc3  CreatedDate: 3/2/2013 Data:ABC
Doc4  CreatedDate: 4/2/2013 Data:ABC
Doc5  CreatedDate: 12/2/2013 Data:ABC

Result should be:

2013 Week1 :2 records
2013 Week7 :2 records
2013 Week8 :1 record


Thanks in advance!

Jamshaid


Re: [Solr 4] Data grouping on weeks

2013-11-11 Thread Erick Erickson
You're probably looking at date math, see:
http://lucene.apache.org/solr/4_5_1/solr-core/org/apache/solr/util/DateMathParser.html

You're probably going to be faceting to get these counts, see facet
ranges here:
http://wiki.apache.org/solr/SimpleFacetParameters#Facet_by_Range

So the start is something like date/YEAR, then gaps of +7DAYS or some such

Best,
Erick


On Mon, Nov 11, 2013 at 10:51 AM, Jamshaid Ashraf jamshaid...@gmail.comwrote:

 Hi,

 I'm new with solr and wanted to group data on weeks, is there any built-in
 date round function so I give date to this function and it return me the
 week of the year.

 For example I query to solr against date (01/01/2013) it should return me
 (1st week of 2013).

 Like I have following documents in solr:

 Doc1  CreatedDate: 1/1/2013 Data:ABC
 Doc2  CreatedDate: 4/1/2013 Data:ABC
 Doc3  CreatedDate: 3/2/2013 Data:ABC
 Doc4  CreatedDate: 4/2/2013 Data:ABC
 Doc5  CreatedDate: 12/2/2013 Data:ABC

 Result should be:

 2013 Week1 :2 records
 2013 Week7 :2 records
 2013 Week8 :1 record


 Thanks in advance!

 Jamshaid