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 climbingrose <cl...@gmail.com> on 2007/07/19 15:45:28 UTC

DisMax query and date boosting

Hi all,

I'm puzzling over how to boost a date field in a DisMax query. Atm, my qf is
"title^5 summary^1". However, what I really want to do is to allow document
with latest "listedDate" to have better score. For example, documents with
listedDate:[NOW-1DAY TO *] have additional score over documents with
listedDate:[* TO NOW-10DAY]. Any idea?

-- 
Regards,

Cuong Hoang

Re: DisMax query and date boosting

Posted by Pieter Berkel <pi...@gmail.com>.
Try using a boost function (bf) parameter like this:

bf=recip(rord(listedDate),1,1000,1000)^2.5

This should boost documents with more recent listedDate so they appear
higher in the results list. For more info see the wiki page on
DismaxRequestHandler and Functions:

http://wiki.apache.org/solr/DisMaxRequestHandler
http://wiki.apache.org/solr/FunctionQuery

cheers,
Piete



On 19/07/07, climbingrose <cl...@gmail.com> wrote:
>
> Hi all,
>
> I'm puzzling over how to boost a date field in a DisMax query. Atm, my qf
> is
> "title^5 summary^1". However, what I really want to do is to allow
> document
> with latest "listedDate" to have better score. For example, documents with
> listedDate:[NOW-1DAY TO *] have additional score over documents with
> listedDate:[* TO NOW-10DAY]. Any idea?
>
> --
> Regards,
>
> Cuong Hoang
>

Re: DisMax query and date boosting

Posted by Daniel Alheiros <Da...@bbc.co.uk>.
I'm using both the qb and the function, so the function gradually boost
fresher documents and the qb act as an extra boost for the most recent ones.

Good to now that it's interesting to avoid such precision, in fact I'm
rounding my times avoiding using NOW, so it's fine for me.

Regards,
Daniel 


On 20/7/07 01:27, "climbingrose" <cl...@gmail.com> wrote:

> Thanks for the answer Chris. The DisMax query handler is just amazing!
> 
> On 7/20/07, Chris Hostetter <ho...@fucit.org> wrote:
>> 
>> 
>> : Just tried the bq approach and it works beautifully. Exactly what I was
>> : looking for. Still, I'd like to know which approach is the preferred?
>> Thanks
>> : again guys.
>> 
>> i personally recommend the function approach, because it gives you a more
>> gradual falloff in terms of the scores of documents ... the BQ approahc
>> works great for simple boosting of "things in the last N days should score
>> really high" but 1 millisecond after that cut off the score plummets
>> immediately.
>> 
>> side note...
>> 
>> : > > Sorry just correcting myself:
>> : > > <str name="bq">your_date_field:[NOW-24HOURS TO NOW]^ 10.0</str>
>> 
>> the first example is perfectly fine, and will be more efficient because it
>> will take better advantage of the field cache...
>> 
>> : > > > <str name="bq">your_date_field:[NOW/DAY-24HOURS TO NOW]^10.0</str>
>> 
>> ...if you don't round down to the nearest day, then every request will
>> generate a new query which will get put in the filterCache.  if a day
>> isn't granular enough for you, you can round to the nearest hour (or even
>> minute) but i strongly suggest you round to something so you don't wind up
>> using millisecond precision....
>> 
>> <str name="bq">your_date_field:[NOW/HOUR-1DAY TO NOW]^10.0</str>
>> 
>> 
>> 
>> -Hoss
>> 
>> 
> 


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
					

Re: DisMax query and date boosting

Posted by climbingrose <cl...@gmail.com>.
Thanks for the answer Chris. The DisMax query handler is just amazing!

On 7/20/07, Chris Hostetter <ho...@fucit.org> wrote:
>
>
> : Just tried the bq approach and it works beautifully. Exactly what I was
> : looking for. Still, I'd like to know which approach is the preferred?
> Thanks
> : again guys.
>
> i personally recommend the function approach, because it gives you a more
> gradual falloff in terms of the scores of documents ... the BQ approahc
> works great for simple boosting of "things in the last N days should score
> really high" but 1 millisecond after that cut off the score plummets
> immediately.
>
> side note...
>
> : > > Sorry just correcting myself:
> : > > <str name="bq">your_date_field:[NOW-24HOURS TO NOW]^ 10.0</str>
>
> the first example is perfectly fine, and will be more efficient because it
> will take better advantage of the field cache...
>
> : > > > <str name="bq">your_date_field:[NOW/DAY-24HOURS TO NOW]^10.0</str>
>
> ...if you don't round down to the nearest day, then every request will
> generate a new query which will get put in the filterCache.  if a day
> isn't granular enough for you, you can round to the nearest hour (or even
> minute) but i strongly suggest you round to something so you don't wind up
> using millisecond precision....
>
> <str name="bq">your_date_field:[NOW/HOUR-1DAY TO NOW]^10.0</str>
>
>
>
> -Hoss
>
>


-- 
Regards,

Cuong Hoang

Re: DisMax query and date boosting

Posted by Chris Hostetter <ho...@fucit.org>.
: Just tried the bq approach and it works beautifully. Exactly what I was
: looking for. Still, I'd like to know which approach is the preferred? Thanks
: again guys.

i personally recommend the function approach, because it gives you a more
gradual falloff in terms of the scores of documents ... the BQ approahc
works great for simple boosting of "things in the last N days should score
really high" but 1 millisecond after that cut off the score plummets
immediately.

side note...

: > > Sorry just correcting myself:
: > > <str name="bq">your_date_field:[NOW-24HOURS TO NOW]^ 10.0</str>

the first example is perfectly fine, and will be more efficient because it
will take better advantage of the field cache...

: > > > <str name="bq">your_date_field:[NOW/DAY-24HOURS TO NOW]^10.0</str>

...if you don't round down to the nearest day, then every request will
generate a new query which will get put in the filterCache.  if a day
isn't granular enough for you, you can round to the nearest hour (or even
minute) but i strongly suggest you round to something so you don't wind up
using millisecond precision....

<str name="bq">your_date_field:[NOW/HOUR-1DAY TO NOW]^10.0</str>



-Hoss


Re: DisMax query and date boosting

Posted by climbingrose <cl...@gmail.com>.
Just tried the bq approach and it works beautifully. Exactly what I was
looking for. Still, I'd like to know which approach is the preferred? Thanks
again guys.

On 7/20/07, climbingrose <cl...@gmail.com> wrote:
>
> Thanks for both answers. Which one is better in terms of performance? bq
> or bf?
>
> On 7/20/07, Daniel Alheiros < Daniel.Alheiros@bbc.co.uk> wrote:
> >
> > Sorry just correcting myself:
> > <str name="bq">your_date_field:[NOW-24HOURS TO NOW]^ 10.0</str>
> >
> > Regards,
> > Daniel
> >
> > On 19/7/07 15:25, "Daniel Alheiros" <Da...@bbc.co.uk> wrote:
> >
> > > I think in this case you can use a "bq" (Boost Query) so you can apply
> > this
> > > boost to the range you want.
> > >
> > > <str name="bq">your_date_field:[NOW/DAY-24HOURS TO NOW]^10.0</str>
> > >
> > > This example will boost your documents with date within the last 24h.
> > >
> > > Regards,
> > > Daniel
> > >
> > > On 19/7/07 14:45, "climbingrose" <cl...@gmail.com> wrote:
> > >
> > >> Hi all,
> > >>
> > >> I'm puzzling over how to boost a date field in a DisMax query. Atm,
> > my qf is
> > >> "title^5 summary^1". However, what I really want to do is to allow
> > document
> > >> with latest "listedDate" to have better score. For example, documents
> > with
> > >> listedDate:[NOW-1DAY TO *] have additional score over documents with
> > >> listedDate:[* TO NOW-10DAY]. Any idea?
> > >
> > >
> > > http://www.bbc.co.uk/
> > > This e-mail (and any attachments) is confidential and may contain
> > personal
> > > views which are not the views of the BBC unless specifically stated.
> > > If you have received it in error, please delete it from your system.
> > > Do not use, copy or disclose the information in any way nor act in
> > reliance on
> > > it and notify the sender immediately.
> > > Please note that the BBC monitors e-mails sent or received.
> > > Further communication will signify your consent to this.
> > >
> >
> >
> > http://www.bbc.co.uk/
> > This e-mail (and any attachments) is confidential and may contain
> > personal views which are not the views of the BBC unless specifically
> > stated.
> > If you have received it in error, please delete it from your system.
> > Do not use, copy or disclose the information in any way nor act in
> > reliance on it and notify the sender immediately.
> > Please note that the BBC monitors e-mails sent or received.
> > Further communication will signify your consent to this.
> >
> >
>
>
> --
> Regards,
>
> Cuong Hoang




-- 
Regards,

Cuong Hoang

Re: DisMax query and date boosting

Posted by climbingrose <cl...@gmail.com>.
Thanks for both answers. Which one is better in terms of performance? bq or
bf?

On 7/20/07, Daniel Alheiros <Da...@bbc.co.uk> wrote:
>
> Sorry just correcting myself:
> <str name="bq">your_date_field:[NOW-24HOURS TO NOW]^10.0</str>
>
> Regards,
> Daniel
>
> On 19/7/07 15:25, "Daniel Alheiros" <Da...@bbc.co.uk> wrote:
>
> > I think in this case you can use a "bq" (Boost Query) so you can apply
> this
> > boost to the range you want.
> >
> > <str name="bq">your_date_field:[NOW/DAY-24HOURS TO NOW]^10.0</str>
> >
> > This example will boost your documents with date within the last 24h.
> >
> > Regards,
> > Daniel
> >
> > On 19/7/07 14:45, "climbingrose" <cl...@gmail.com> wrote:
> >
> >> Hi all,
> >>
> >> I'm puzzling over how to boost a date field in a DisMax query. Atm, my
> qf is
> >> "title^5 summary^1". However, what I really want to do is to allow
> document
> >> with latest "listedDate" to have better score. For example, documents
> with
> >> listedDate:[NOW-1DAY TO *] have additional score over documents with
> >> listedDate:[* TO NOW-10DAY]. Any idea?
> >
> >
> > http://www.bbc.co.uk/
> > This e-mail (and any attachments) is confidential and may contain
> personal
> > views which are not the views of the BBC unless specifically stated.
> > If you have received it in error, please delete it from your system.
> > Do not use, copy or disclose the information in any way nor act in
> reliance on
> > it and notify the sender immediately.
> > Please note that the BBC monitors e-mails sent or received.
> > Further communication will signify your consent to this.
> >
>
>
> http://www.bbc.co.uk/
> This e-mail (and any attachments) is confidential and may contain personal
> views which are not the views of the BBC unless specifically stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in
> reliance on it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>
>


-- 
Regards,

Cuong Hoang

Re: DisMax query and date boosting

Posted by Daniel Alheiros <Da...@bbc.co.uk>.
Sorry just correcting myself:
<str name="bq">your_date_field:[NOW-24HOURS TO NOW]^10.0</str>

Regards,
Daniel

On 19/7/07 15:25, "Daniel Alheiros" <Da...@bbc.co.uk> wrote:

> I think in this case you can use a "bq" (Boost Query) so you can apply this
> boost to the range you want.
> 
> <str name="bq">your_date_field:[NOW/DAY-24HOURS TO NOW]^10.0</str>
> 
> This example will boost your documents with date within the last 24h.
> 
> Regards,
> Daniel
> 
> On 19/7/07 14:45, "climbingrose" <cl...@gmail.com> wrote:
> 
>> Hi all,
>> 
>> I'm puzzling over how to boost a date field in a DisMax query. Atm, my qf is
>> "title^5 summary^1". However, what I really want to do is to allow document
>> with latest "listedDate" to have better score. For example, documents with
>> listedDate:[NOW-1DAY TO *] have additional score over documents with
>> listedDate:[* TO NOW-10DAY]. Any idea?
> 
> 
> http://www.bbc.co.uk/
> This e-mail (and any attachments) is confidential and may contain personal
> views which are not the views of the BBC unless specifically stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in reliance on
> it and notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
> 


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
					

Re: DisMax query and date boosting

Posted by Daniel Alheiros <Da...@bbc.co.uk>.
I think in this case you can use a "bq" (Boost Query) so you can apply this
boost to the range you want.

<str name="bq">your_date_field:[NOW/DAY-24HOURS TO NOW]^10.0</str>

This example will boost your documents with date within the last 24h.

Regards,
Daniel

On 19/7/07 14:45, "climbingrose" <cl...@gmail.com> wrote:

> Hi all,
> 
> I'm puzzling over how to boost a date field in a DisMax query. Atm, my qf is
> "title^5 summary^1". However, what I really want to do is to allow document
> with latest "listedDate" to have better score. For example, documents with
> listedDate:[NOW-1DAY TO *] have additional score over documents with
> listedDate:[* TO NOW-10DAY]. Any idea?


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.