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 ufuk yılmaz <uy...@vivaldi.net.INVALID> on 2020/12/24 21:42:40 UTC

Range faceting on timestamp field

Hello all,

I have a plong field in my schema representing a Unix timestamp

<field name="timestamp_s" type="plong" indexed="true"/>

I’m doing a range facet over this field to find which event occured on which day. I’m setting “start” on some date at 00:00 o’clock, end on another, and setting gap to 86400 (total seconds in a day)
...
"type": "range",
"field": "timestamp_s",
"start": 1338498000,
"end": 1339275600,
"gap": 86400,
...

Lets say that an event occured at 19:00 GMT+00. This facet puts it in the bucket of that day, which starts at 00:00. I’m living in GMT+2 timezone, so clock was 21:00 and that event occured on the same day with me, which is all good and correct.

Another event occured at 23:00 GMT+00, Day 2. At that time, it was 01:00 Day 3 here. Faceting puts the event at Day 2 00:00’s bucket, when converted to my timezone, puts the event on Day 2. But it was Day 3 here when the event happened...

I wish I didn’t bore the hell out of you. Do you have any suggestion to solve this problem? Unfortunately my timestamp field is not a date field and I need to show the results from my perspective, not from the universal time.

Have a nice day!

Sent from Mail for Windows 10


Re: Range faceting on timestamp field

Posted by Erick Erickson <er...@gmail.com>.
Then you need to form your start at relative to your timezone.

What I’d actually recommend is that if you need to bucket by day,
you index the day in a separate field. Of course, if you have to
bucket by day in arbitrary timezones that won’t work…..

Best,
Erick

> On Dec 24, 2020, at 4:42 PM, ufuk yılmaz <uy...@vivaldi.net.INVALID> wrote:
> 
> Hello all,
> 
> I have a plong field in my schema representing a Unix timestamp
> 
> <field name="timestamp_s" type="plong" indexed="true"/>
> 
> I’m doing a range facet over this field to find which event occured on which day. I’m setting “start” on some date at 00:00 o’clock, end on another, and setting gap to 86400 (total seconds in a day)
> ...
> "type": "range",
> "field": "timestamp_s",
> "start": 1338498000,
> "end": 1339275600,
> "gap": 86400,
> ...
> 
> Lets say that an event occured at 19:00 GMT+00. This facet puts it in the bucket of that day, which starts at 00:00. I’m living in GMT+2 timezone, so clock was 21:00 and that event occured on the same day with me, which is all good and correct.
> 
> Another event occured at 23:00 GMT+00, Day 2. At that time, it was 01:00 Day 3 here. Faceting puts the event at Day 2 00:00’s bucket, when converted to my timezone, puts the event on Day 2. But it was Day 3 here when the event happened...
> 
> I wish I didn’t bore the hell out of you. Do you have any suggestion to solve this problem? Unfortunately my timestamp field is not a date field and I need to show the results from my perspective, not from the universal time.
> 
> Have a nice day!
> 
> Sent from Mail for Windows 10
>