Elastic simple search considering timezones

Hi all,

I have an issue that requires timezone handling, meaning that I need to use
dates given by user (in a certain timezone) to search in ES.
All dates indexed to ES are UTC, and what I'm looking for is a way to tell
ES that query dates are in a certain timezone, which internally would do
the maths to turn them to UTC and give me back results in the user timezone.

Is this possible?

Thanks!

--

On Tue, 2012-11-27 at 09:07 -0800, Vania S. wrote:

Hi all,

I have an issue that requires timezone handling, meaning that I need
to use dates given by user (in a certain timezone) to search in ES.
All dates indexed to ES are UTC, and what I'm looking for is a way to
tell ES that query dates are in a certain timezone, which internally
would do the maths to turn them to UTC and give me back results in the
user timezone.

What do you mean by "give me back results in the user timezone"?

You get back the original document (unless you're talking about facets).

But, you can do eg a range filter and include the timezone information
in the date:

{ range: { my_date: { gte: "2012-01-01T09:00:00+03:00" }}}

clint

--

Hi,

Thanks for your answer.

I meant, "give me back results that match user timezone".
My dates are indexed in this format "yyyy-mm-dd hh:mm:ss" and that is also
the format user is expecting to insert in queries.

Thanks,

On Tuesday, November 27, 2012 5:22:35 PM UTC, Clinton Gormley wrote:

On Tue, 2012-11-27 at 09:07 -0800, Vania S. wrote:

Hi all,

I have an issue that requires timezone handling, meaning that I need
to use dates given by user (in a certain timezone) to search in ES.
All dates indexed to ES are UTC, and what I'm looking for is a way to
tell ES that query dates are in a certain timezone, which internally
would do the maths to turn them to UTC and give me back results in the
user timezone.

What do you mean by "give me back results in the user timezone"?

You get back the original document (unless you're talking about facets).

But, you can do eg a range filter and include the timezone information
in the date:

{ range: { my_date: { gte: "2012-01-01T09:00:00+03:00" }}}

clint

--

I meant, "give me back results that match user timezone".
My dates are indexed in this format "yyyy-mm-dd hh:mm:ss" and that is
also the format user is expecting to insert in queries.

As I said, you get back exactly what you put in, so no - you would have
to handle that conversion in your application

clint

Thanks,

On Tuesday, November 27, 2012 5:22:35 PM UTC, Clinton Gormley wrote:
On Tue, 2012-11-27 at 09:07 -0800, Vania S. wrote:
> Hi all,
>
>
> I have an issue that requires timezone handling, meaning
that I need
> to use dates given by user (in a certain timezone) to search
in ES.
> All dates indexed to ES are UTC, and what I'm looking for is
a way to
> tell ES that query dates are in a certain timezone, which
internally
> would do the maths to turn them to UTC and give me back
results in the
> user timezone.

    What do you mean by "give me back results in the user
    timezone"? 
    
    You get back the original document (unless you're talking
    about facets). 
    
    But, you can do eg a range filter and include the timezone
    information 
    in the date: 
    
      { range: { my_date: { gte: "2012-01-01T09:00:00+03:00" }}} 
    
    clint 

--

--

Thanks clint!

On Tuesday, November 27, 2012 5:07:43 PM UTC, Vania S. wrote:

Hi all,

I have an issue that requires timezone handling, meaning that I need to
use dates given by user (in a certain timezone) to search in ES.
All dates indexed to ES are UTC, and what I'm looking for is a way to tell
ES that query dates are in a certain timezone, which internally would do
the maths to turn them to UTC and give me back results in the user timezone.

Is this possible?

Thanks!

--

By the way, the date math can be used in this case?

To do something like:

{
"filter": {
"range": {
"creationDate": {
"from": "2012-11-21 11:48:31||+1h",
"to": "2012-11-21 11:48:31",
"include_lower": true,
"include_upper": true
}
}
}
}

Thanks!

On Tuesday, November 27, 2012 5:30:40 PM UTC, Vania S. wrote:

Thanks clint!

On Tuesday, November 27, 2012 5:07:43 PM UTC, Vania S. wrote:

Hi all,

I have an issue that requires timezone handling, meaning that I need to
use dates given by user (in a certain timezone) to search in ES.
All dates indexed to ES are UTC, and what I'm looking for is a way to
tell ES that query dates are in a certain timezone, which internally would
do the maths to turn them to UTC and give me back results in the user
timezone.

Is this possible?

Thanks!

--

On Tue, 2012-11-27 at 10:15 -0800, Vania S. wrote:

By the way, the date math can be used in this case?

yes, but it won't change the date formats that are returned to you. So
this has the same effect as my example in the first email

clint

To do something like:

{
"filter": {
"range": {
"creationDate": {
"from": "2012-11-21 11:48:31||+1h",
"to": "2012-11-21 11:48:31",
"include_lower": true,
"include_upper": true
}
}
}
}

Thanks!

On Tuesday, November 27, 2012 5:30:40 PM UTC, Vania S. wrote:
Thanks clint!

    On Tuesday, November 27, 2012 5:07:43 PM UTC, Vania S. wrote:
            Hi all,
            
            
            I have an issue that requires timezone handling,
            meaning that I need to use dates given by user (in a
            certain timezone) to search in ES.
            All dates indexed to ES are UTC, and what I'm looking
            for is a way to tell ES that query dates are in a
            certain timezone, which internally would do the maths
            to turn them to UTC and give me back results in the
            user timezone.
            
            
            Is this possible?
            
            
            Thanks!

--

--

True, but this way I don't have to change my indexed date formats... I can
still have "yyyy-mm-dd hh:mm:ss" and just add the "timezone" as ||+/+TZh,
right?

On Tue, Nov 27, 2012 at 6:18 PM, Clinton Gormley clint@traveljury.comwrote:

On Tue, 2012-11-27 at 10:15 -0800, Vania S. wrote:

By the way, the date math can be used in this case?

yes, but it won't change the date formats that are returned to you. So
this has the same effect as my example in the first email

clint

To do something like:

{
"filter": {
"range": {
"creationDate": {
"from": "2012-11-21 11:48:31||+1h",
"to": "2012-11-21 11:48:31",
"include_lower": true,
"include_upper": true
}
}
}
}

Thanks!

On Tuesday, November 27, 2012 5:30:40 PM UTC, Vania S. wrote:
Thanks clint!

    On Tuesday, November 27, 2012 5:07:43 PM UTC, Vania S. wrote:
            Hi all,


            I have an issue that requires timezone handling,
            meaning that I need to use dates given by user (in a
            certain timezone) to search in ES.
            All dates indexed to ES are UTC, and what I'm looking
            for is a way to tell ES that query dates are in a
            certain timezone, which internally would do the maths
            to turn them to UTC and give me back results in the
            user timezone.


            Is this possible?


            Thanks!

--

--

--
Vânia Santos

--

On Tue, 2012-11-27 at 18:24 +0000, Vânia Santos wrote:

True, but this way I don't have to change my indexed date formats... I
can still have "yyyy-mm-dd hh:mm:ss" and just add the "timezone" as ||
+/+TZh, right?

Yes, but I never suggested that you did need to change your indexed date
formats :slight_smile:

clint

--

I'll try either ways!

Thanks!

On Tue, Nov 27, 2012 at 6:32 PM, Clinton Gormley clint@traveljury.comwrote:

On Tue, 2012-11-27 at 18:24 +0000, Vânia Santos wrote:

True, but this way I don't have to change my indexed date formats... I
can still have "yyyy-mm-dd hh:mm:ss" and just add the "timezone" as ||
+/+TZh, right?

Yes, but I never suggested that you did need to change your indexed date
formats :slight_smile:

clint

--

--
Vânia Santos

--