Hi Yonik, Thank you for the reply. I followed your link and this feature is really awesome to have. But, unfortunately I am using solr 4.4 on cloudera right now. I tried this. Looks like it does not work for this version. Sorry, I forgot to mention that in my original mail.
Thanks, Lewin -----Original Message----- From: Yonik Seeley [mailto:ysee...@gmail.com] Sent: Monday, August 17, 2015 12:26 PM To: solr-user@lucene.apache.org Subject: Re: SOLR to pivot on date range query The JSON Facet API can embed any type of facet within any other type: http://yonik.com/json-facet-api/ json.facet={ dates : { type : range, field : entryDate, start : "2001-...", // use full solr date format end : "2015...", gap : "+1MONTH", facet : { type:terms, field:entryType } } } -Yonik On Mon, Aug 17, 2015 at 3:16 PM, Lewin Joy (TMS) <lewin_...@toyota.com> wrote: > Hi, > > I have data that is coming in everyday. I need to query the index for a time > range and give the facet counts ordered by different months. > For this, I just have a solr date field, entryDate which captures the time. > > How do I make this query? I need the results like below. > > Jan-2015 (2000) > entryType=Sales(750) > entryType=Complaints(200) > entryType=Feedback(450) > Feb-2015(3200) > entryType=Sales(1000) > entryType=Complaints(250) > entryType=Feedback(600) > Mar-2015(2800) > entryType=Sales(980) > entryType=Complaints(220) > entryType=Feedback(400) > > > I tried Range queries on 'entryDate' field to order the result facets by > month. > But, I am not able to pivot on the 'entryType' field to bring the counts of > "sales,complaints and feedback" type record by month. > > For now, I am creating another field at index time to have the value for > "MONTH-YEAR" derived from the 'entryDate' field. > But for older records, it becomes a hassle. Is there a way I can handle this > at query time? > Or is there a better way to handle this situation? > > Please let me know. Any thoughts / suggestions are valuable. > > Thanks, > Lewin >