Two options come to mind -

  * index a field for just the month names
  * leverage facet.query…

      &facet.query={!key=Jan}cdate:[2003-01-01 TO 2003-01-31] OR 
cdate:[2004-01-01 TO 2004-01-31]…. 

I don’t know a way to select just “January’s” from a date field any more 
elegantly than that.  

I’d really go with indexing the month names (in addition to the full date too).


> On Sep 20, 2016, at 5:47 PM, Aswath Srinivasan (TMS) 
> <> wrote:
> Hello,
> How to build a Month facet from a date field? The facet that I’m looking for 
> should have a maximum of only 12 buckets. The possible bucket values are Jan, 
> Feb, Mar,…. Nov, Dec.
> http://localhost:8983/solr/collection1/select?facet=on&rows=0&indent=on&q=*:*&wt=json&json.facet.category={type:range,field:cdate,start:"2000-01-01T00:00:00Z",end:NOW,gap:"+1MONTH"}}<http://localhost:8983/solr/pqss_cis/select?facet=on&rows=0&indent=on&q=*:*&wt=json&json.facet.category=%7btype:range,field:cdate,start:%222003-01-01T00:00:00Z%22,end:NOW,gap:%22+1MONTH%22%7d%7d>
> This is the query that I have so far but this doesn’t group the facet by 
> Month, obviously, because of the gap:"+1MONTH"
> Really appreciate the help.
> Aswath NS

Reply via email to