creating date facets

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

creating date facets

Nightingale, Jonathan A (US)
Hi all,
I'm trying to have a date field automatically generate some facets of itself, like hour of the day and hour of the week as examples, when its stored. I was looking at this tutorial and it deemed to almost do what I wanted

https://nathanfriend.io/2017/06/26/smart-date-searching-with-solr.html

I was wondering if there was a way to use these filters and tokenizers to generate values for different fields. Maybe in conjunction with a copyfield?

I'd like it to work whenever a *_c (calendar) field is indexed it also indexes the hour of the day (hod_d) and hor of week (how_d) fields as well.

Any thoughts?

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: creating date facets

Erick Erickson
There are two approaches I might use, which is really up to you.

- You can do a regex filter. So define your extra fields as you want, then use a regex charFilter (NOT filter, you want to transform the entire input) to peel out the separate parts. Then copyfield to each one, each with a different regex to peel out the correct part.

- use a ScriptUpdateProcessor to do whatever you want in the scripting language you’re most comfortable with. Note that the SolrDocument that’s handled by a SUP is just a map of key:value pairs and you can modify it as you see fit.

Best,
Erick

> On Jun 19, 2019, at 10:25 AM, Nightingale, Jonathan A (US) <[hidden email]> wrote:
>
> Hi all,
> I'm trying to have a date field automatically generate some facets of itself, like hour of the day and hour of the week as examples, when its stored. I was looking at this tutorial and it deemed to almost do what I wanted
>
> https://nathanfriend.io/2017/06/26/smart-date-searching-with-solr.html
>
> I was wondering if there was a way to use these filters and tokenizers to generate values for different fields. Maybe in conjunction with a copyfield?
>
> I'd like it to work whenever a *_c (calendar) field is indexed it also indexes the hour of the day (hod_d) and hor of week (how_d) fields as well.
>
> Any thoughts?
>
> Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: creating date facets

Joel Bernstein
You might find this useful. If makes creating time series aggregations a
little easier. It uses JSON facets under the covers and is very fast.

https://lucene.apache.org/solr/guide/7_6/stream-source-reference.html#timeseries

Joel Bernstein
http://joelsolr.blogspot.com/


On Wed, Jun 19, 2019 at 1:34 PM Erick Erickson <[hidden email]>
wrote:

> There are two approaches I might use, which is really up to you.
>
> - You can do a regex filter. So define your extra fields as you want, then
> use a regex charFilter (NOT filter, you want to transform the entire input)
> to peel out the separate parts. Then copyfield to each one, each with a
> different regex to peel out the correct part.
>
> - use a ScriptUpdateProcessor to do whatever you want in the scripting
> language you’re most comfortable with. Note that the SolrDocument that’s
> handled by a SUP is just a map of key:value pairs and you can modify it as
> you see fit.
>
> Best,
> Erick
>
> > On Jun 19, 2019, at 10:25 AM, Nightingale, Jonathan A (US) <
> [hidden email]> wrote:
> >
> > Hi all,
> > I'm trying to have a date field automatically generate some facets of
> itself, like hour of the day and hour of the week as examples, when its
> stored. I was looking at this tutorial and it deemed to almost do what I
> wanted
> >
> > https://nathanfriend.io/2017/06/26/smart-date-searching-with-solr.html
> >
> > I was wondering if there was a way to use these filters and tokenizers
> to generate values for different fields. Maybe in conjunction with a
> copyfield?
> >
> > I'd like it to work whenever a *_c (calendar) field is indexed it also
> indexes the hour of the day (hod_d) and hor of week (how_d) fields as well.
> >
> > Any thoughts?
> >
> > Thanks!
>
>
Reply | Threaded
Open this post in threaded view
|

RE: creating date facets

Nightingale, Jonathan A (US)
In reply to this post by Erick Erickson
I was thinking of doing a copy field to a special tokenizer

I can't use a regex because I want to get a decimal value for the hour+ minutes so I need to calculate that. It's not just part for the date string.

So I'll calculate 60*hours + minutes / 60 and put it into a double field for hour of the day

-----Original Message-----
From: Erick Erickson <[hidden email]>
Sent: Wednesday, June 19, 2019 1:34 PM
To: [hidden email]
Subject: Re: creating date facets

*** WARNING ***
EXTERNAL EMAIL -- This message originates from outside our organization.


There are two approaches I might use, which is really up to you.

- You can do a regex filter. So define your extra fields as you want, then use a regex charFilter (NOT filter, you want to transform the entire input) to peel out the separate parts. Then copyfield to each one, each with a different regex to peel out the correct part.

- use a ScriptUpdateProcessor to do whatever you want in the scripting language you’re most comfortable with. Note that the SolrDocument that’s handled by a SUP is just a map of key:value pairs and you can modify it as you see fit.

Best,
Erick

> On Jun 19, 2019, at 10:25 AM, Nightingale, Jonathan A (US) <[hidden email]> wrote:
>
> Hi all,
> I'm trying to have a date field automatically generate some facets of itself, like hour of the day and hour of the week as examples, when its stored. I was looking at this tutorial and it deemed to almost do what I wanted
>
> https://nathanfriend.io/2017/06/26/smart-date-searching-with-solr.html
>
> I was wondering if there was a way to use these filters and tokenizers to generate values for different fields. Maybe in conjunction with a copyfield?
>
> I'd like it to work whenever a *_c (calendar) field is indexed it also indexes the hour of the day (hod_d) and hor of week (how_d) fields as well.
>
> Any thoughts?
>
> Thanks!