I think you can specify the current month with

birthDate:[NOW/MONTH TO NOW/MONTH+1MONTH}

does that work for you?

On Wed, Mar 14, 2018 at 6:32 AM, Emir Arnautović <
emir.arnauto...@sematext.com> wrote:

> Actually you don’t have to add another field - there is function ms that
> converts date to timestamp. What you can do is use frange query parser and
> play bit with math, e.g. sub(ms(date_field),ms(NOW/YEAR)) will give you
> ms elapsed since this year and you know that from 0 to 31*86400000 is
> January, from 31*86400000+1 to … is February and so on.
>
> If you go this path, I would suggest custom function that will convert
> date to month/year.
>
> HTH,
> Emir
> --
> Monitoring - Log Management - Alerting - Anomaly Detection
> Solr & Elasticsearch Consulting Support Training - http://sematext.com/
>
>
>
> > On 14 Mar 2018, at 10:53, Albert Lee <albertlee8...@gmail.com> wrote:
> >
> > I don’t want to add separate fields since I have many dates to index.
> How to index it as timestamp and do function query, any example or
> documentation?
> >
> > Regards,
> > Albert
> >
> > From: Emir Arnautović
> > Sent: Wednesday, March 14, 2018 5:38 PM
> > To: solr-user@lucene.apache.org
> > Subject: Re: solr query
> >
> > Hi Albert,
> > The simplest solution is to index month/year as separate fields.
> Alternative is to index it as timestamp and do function query to do some
> math and filter out records.
> >
> > Emir
> > --
> > Monitoring - Log Management - Alerting - Anomaly Detection
> > Solr & Elasticsearch Consulting Support Training - http://sematext.com/
> >
> >
> >
> >> On 14 Mar 2018, at 10:31, Albert Lee <albertlee8...@gmail.com> wrote:
> >>
> >> NOW/MONTH and NOW/YEAR to get the start of month/year, but how can I
> get current month of regardless year. Like the use case,  people who’s
> birthdate is this month?
> >>
> >> Regard,
> >> Albert
> >>
> >>
> >> From: Emir Arnautović
> >> Sent: Wednesday, March 14, 2018 5:26 PM
> >> To: solr-user@lucene.apache.org
> >> Subject: Re: solr query
> >>
> >> Hi Albert,
> >> It does - you can use NOW/MONTH and NOW/YEAR to get the start of
> month/year. Here is reference to date math: https://lucene.apache.org/
> solr/guide/6_6/working-with-dates.html#WorkingwithDates-DateMathSyntax <
> https://lucene.apache.org/solr/guide/6_6/working-with-
> dates.html#WorkingwithDates-DateMathSyntax>
> >>
> >> HTH,
> >> Emir
> >> --
> >> Monitoring - Log Management - Alerting - Anomaly Detection
> >> Solr & Elasticsearch Consulting Support Training - http://sematext.com/
> >>
> >>
> >>
> >>> On 14 Mar 2018, at 04:21, Albert Lee <albertlee8...@gmail.com> wrote:
> >>>
> >>> Dear Solr,
> >>> I want to whether solr support query by this year or this month?
> >>> If can, how to do that.
> >>> Thanks.
> >>>
> >>> Regards,
> >>> Albert
> >>>
> >>
> >>
> >
> >
>
>


-- 
http://www.the111shift.com

Reply via email to