lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <ysee...@gmail.com>
Subject Re: SOLR to pivot on date range query
Date Mon, 17 Aug 2015 19:25:55 GMT
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_Joy@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
>

Mime
View raw message