Dan
Dan

Reputation: 326

Time Zone Aware Date Facets in Solr

I need to be able to return a series of Facet counts in solr, grouped by Date, and Time Zone aware. I can get groupings back by day, but when providing a timezone, it just alters the group so that all groups are no longer adjusted to the beginning of the day - they are just off by the time zone adjustment. Which doesn't really provide the right information.

I have the following Solr Query:

GMT, How Delightful!

   "2015-08-12T00:00:00Z":1,
   "2015-08-13T00:00:00Z":3,
   "2015-08-14T00:00:00Z":2,
   "2015-08-17T00:00:00Z":2,
   "2015-08-18T00:00:00Z":6,

LA Time Zone, So Sad.

When I add in the following parameter: TZ=America/Los_Angeles

   "2015-08-12T07:00:00Z":1,
   "2015-08-13T07:00:00Z":3,
   "2015-08-14T07:00:00Z":2,
   "2015-08-17T07:00:00Z":2,
   "2015-08-18T07:00:00Z":6,

Am I missing some simple solution, or is this the best I can do?

Upvotes: 1

Views: 557

Answers (1)

Dan
Dan

Reputation: 326

This is returning precisely the data that is required. I thought I was seeing it in the timezone I requested, but what you get is in GMT - with an offset. I was confused when I saw that the facet counts where the same between the two different selections. Using an asian time zone shows that the counts are in fact different:

For GMT:

"facet_dates":{
  "auction_date_utc":{
    "2015-07-17T00:00:00Z":3,
    "2015-07-20T00:00:00Z":10,
    "2015-07-21T00:00:00Z":18,
    "2015-07-22T00:00:00Z":6,
    "2015-07-23T00:00:00Z":4,

For tz="Pacific/Apia"

"facet_dates":{
  "auction_date_utc":{
    "2015-07-17T11:00:00Z":3,
    "2015-07-19T11:00:00Z":1,
    "2015-07-20T11:00:00Z":10,
    "2015-07-21T11:00:00Z":20,
    "2015-07-22T11:00:00Z":3,
    "2015-07-23T11:00:00Z":5,

Upvotes: 1

Related Questions