You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jamshaid Ashraf <ja...@gmail.com> on 2013/11/11 16:51:26 UTC
[Solr 4] Data grouping on weeks
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
Posted by Erick Erickson <er...@gmail.com>.
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 <ja...@gmail.com>wrote:
> 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
>