I it possible to configure solr to show time stamps without the 'Z'- character in the end

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

I it possible to configure solr to show time stamps without the 'Z'- character in the end

Miettinen Jaana (STAT)
Dear recipient,

I have a problem in solr: I should add several (old) time stamps into my solr documents, but all of them are in  local time (UTC+2 or UTC+3 depending on day-light-saving situation). As default solr excepts all time stamps to be in UTC-time and adds the 'Z'-character into the end of the time stamp-strings to indicate, that the date should be considered as UTC-time.

Is it possible to change this 'Z'-notation ? Either I would want to get rid of that 'Z' or change it to denote UTC+2.

I noticed that there's variable SOLR_TIMEZONE in solr-7.6.0/bin/solr.in.sh-file. I changed it to  SOLR_TIMEZONE="EST", re-created my solr-servers, but nothing changed. Why was that configuration file ignored (I also changed the port to check whether it was ignored really) ? And what is the purpose of  SOLR_TIMEZONE-variable ?

Br, Jaana Miettinen
Reply | Threaded
Open this post in threaded view
|

Re: I it possible to configure solr to show time stamps without the 'Z'- character in the end

Erick Erickson
When you ask for a field from Solr, it returns _exactly_ what you gave it. So if you input contains the “Z”, the output will. You have to massage it however you want if you want something different. I can imagine at least 3 ways to do this:

1> create a second field with stored=“true”, indexed=“false”, docValues=“false” as a “string” type. On your real date field, make it stored=“false”. Now you search/group/facet/whatever on hour date field and specify tne new field in your “fl” list. It would be easy to do all this in a ScriptUpdateProcessor so your client(s) wouldn’t have to deal with it.

2> Just have your client app take the date and transform it into something more pleasing.

3> Use a document transformer (see “Transforming Result Documents” in the reference guide) to change the docs on the way out.

However, it’s a different time you’re going to show your users .vs. the actual time in the document. You want to take the “Z” off and/or change it to UTC+2. But that’s mis-informing the user about what the actual time was by 2 hours unless you change the value shown to reflect that.

Best,
Erick


> On Apr 8, 2019, at 3:38 AM, Miettinen Jaana (STAT) <[hidden email]> wrote:
>
> Dear recipient,
>
> I have a problem in solr: I should add several (old) time stamps into my solr documents, but all of them are in  local time (UTC+2 or UTC+3 depending on day-light-saving situation). As default solr excepts all time stamps to be in UTC-time and adds the 'Z'-character into the end of the time stamp-strings to indicate, that the date should be considered as UTC-time.
>
> Is it possible to change this 'Z'-notation ? Either I would want to get rid of that 'Z' or change it to denote UTC+2.
>
> I noticed that there's variable SOLR_TIMEZONE in solr-7.6.0/bin/solr.in.sh-file. I changed it to  SOLR_TIMEZONE="EST", re-created my solr-servers, but nothing changed. Why was that configuration file ignored (I also changed the port to check whether it was ignored really) ? And what is the purpose of  SOLR_TIMEZONE-variable ?
>
> Br, Jaana Miettinen

Reply | Threaded
Open this post in threaded view
|

Re: I it possible to configure solr to show time stamps without the 'Z'- character in the end

Shawn Heisey-2
In reply to this post by Miettinen Jaana (STAT)
On 4/8/2019 4:38 AM, Miettinen Jaana (STAT) wrote:
> I have a problem in solr: I should add several (old) time stamps into my solr documents, but all of them are in  local time (UTC+2 or UTC+3 depending on day-light-saving situation). As default solr excepts all time stamps to be in UTC-time and adds the 'Z'-character into the end of the time stamp-strings to indicate, that the date should be considered as UTC-time.
>
> Is it possible to change this 'Z'-notation ? Either I would want to get rid of that 'Z' or change it to denote UTC+2.

Solr uses UTC.  The "Z" is part of the ISO standard that Solr is using.
I forget which ISO number it is.  So it's always going to be there when
using a date field.

> I noticed that there's variable SOLR_TIMEZONE in solr-7.6.0/bin/solr.in.sh-file. I changed it to  SOLR_TIMEZONE="EST", re-created my solr-servers, but nothing changed. Why was that configuration file ignored (I also changed the port to check whether it was ignored really) ? And what is the purpose of  SOLR_TIMEZONE-variable ?


The timezone information affects date math.  So when you have something
like NOW/WEEK or NOW/DAY, Solr knows when a new day starts and can round
the time correctly.

Timezone information does *NOT* affect the time that does into the index
or the display of information in search results.

If you want your local timezone in your output, you're going to need to
do what programs on UNIX have been doing for decades -- translating the
UTC time they can access to the configured timezone.  It is rare for
Solr's results to be given directly to users -- it nearly always passes
through a custom program.

Thanks,
Shawn
Reply | Threaded
Open this post in threaded view
|

Re: I it possible to configure solr to show time stamps without the 'Z'- character in the end

Jan Høydahl / Cominvent
In reply to this post by Miettinen Jaana (STAT)
Perhaps an UpdateProcessor is what you need?
https://lucene.apache.org/solr/7_7_0//solr-core/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.html <https://lucene.apache.org/solr/7_7_0//solr-core/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.html>
https://lucene.apache.org/solr/guide/7_7/update-request-processors.html <https://lucene.apache.org/solr/guide/7_7/update-request-processors.html>

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

> 8. apr. 2019 kl. 12:38 skrev Miettinen Jaana (STAT) <[hidden email]>:
>
> Dear recipient,
>
> I have a problem in solr: I should add several (old) time stamps into my solr documents, but all of them are in  local time (UTC+2 or UTC+3 depending on day-light-saving situation). As default solr excepts all time stamps to be in UTC-time and adds the 'Z'-character into the end of the time stamp-strings to indicate, that the date should be considered as UTC-time.
>
> Is it possible to change this 'Z'-notation ? Either I would want to get rid of that 'Z' or change it to denote UTC+2.
>
> I noticed that there's variable SOLR_TIMEZONE in solr-7.6.0/bin/solr.in.sh-file. I changed it to  SOLR_TIMEZONE="EST", re-created my solr-servers, but nothing changed. Why was that configuration file ignored (I also changed the port to check whether it was ignored really) ? And what is the purpose of  SOLR_TIMEZONE-variable ?
>
> Br, Jaana Miettinen