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 Sammy Yu <te...@gmail.com> on 2008/12/04 22:35:45 UTC

Standard request with functional query

Hi guys,
    I have a standard query that searches across multiple text fields such as
q=title:iphone OR bodytext:iphone OR title:firmware OR bodytext:firmware

This comes back with documents that have iphone and firmware (I know I
can use dismax handler but it seems to be really slow), which is
great.  Now I want to give some more weight to more recent documents
(there is a dateCreated field in each document).

So I've modified the query as such:
(title:iphone OR bodytext:iphone OR title:firmware OR
bodytext:firmware) AND _val_:"ord(dateCreated)"^0.1
URLencoded to q=(title%3Aiphone+OR+bodytext%3Aiphone+OR+title%3Afirmware+OR+bodytext%3Afirmware)+AND+_val_%3A"ord(dateCreated)"^0.1

However, the results are not as one would expects.  The first few
documents only come back with the word iphone and appears to be sorted
by date created.  It seems to completely ignore the score and use the
dateCreated field for the score.

On a not directly related issue it seems like if you put the weight
within the double quotes:
(title:iphone OR bodytext:iphone OR title:firmware OR
bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"

the parser complains:
org.apache.lucene.queryParser.ParseException: Cannot parse
'(title:iphone OR bodytext:iphone OR title:firmware OR
bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"': Expected ',' at
position 16 in 'ord(dateCreated)^0.1'

Thanks,
Sammy

Re: Standard request with functional query

Posted by Chris Hostetter <ho...@fucit.org>.
:     Thanks for the response, but how would make recency a factor on
: scoring documents with the standard request handler.
: The query (title:iphone OR bodytext:iphone OR title:firmware OR
: bodytext:firmware) AND _val_:"ord(dateCreated)"^0.1
: seems to do something very similar to just sorting by dateCreated
: rather than having dateCreated being a part of the score.

you have to look at the score explanations (debugQuery=true) and decide 
what boost is appropriate.  there are no magic numbers that work for 
everyone.

: 
: Thanks,
: Sammy
: 
: n Thu, Dec 4, 2008 at 1:35 PM, Sammy Yu <te...@gmail.com> wrote:
: > Hi guys,
: >    I have a standard query that searches across multiple text fields such as
: > q=title:iphone OR bodytext:iphone OR title:firmware OR bodytext:firmware
: >
: > This comes back with documents that have iphone and firmware (I know I
: > can use dismax handler but it seems to be really slow), which is
: > great.  Now I want to give some more weight to more recent documents
: > (there is a dateCreated field in each document).
: >
: > So I've modified the query as such:
: > (title:iphone OR bodytext:iphone OR title:firmware OR
: > bodytext:firmware) AND _val_:"ord(dateCreated)"^0.1
: > URLencoded to q=(title%3Aiphone+OR+bodytext%3Aiphone+OR+title%3Afirmware+OR+bodytext%3Afirmware)+AND+_val_%3A"ord(dateCreated)"^0.1
: >
: > However, the results are not as one would expects.  The first few
: > documents only come back with the word iphone and appears to be sorted
: > by date created.  It seems to completely ignore the score and use the
: > dateCreated field for the score.
: >
: > On a not directly related issue it seems like if you put the weight
: > within the double quotes:
: > (title:iphone OR bodytext:iphone OR title:firmware OR
: > bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"
: >
: > the parser complains:
: > org.apache.lucene.queryParser.ParseException: Cannot parse
: > '(title:iphone OR bodytext:iphone OR title:firmware OR
: > bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"': Expected ',' at
: > position 16 in 'ord(dateCreated)^0.1'
: >
: > Thanks,
: > Sammy
: >
: 



-Hoss


Re: Standard request with functional query

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Sammy:

http://markmail.org/search/solr+function+query+recip?page=1

Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch



----- Original Message ----
> From: Sammy Yu <te...@gmail.com>
> To: solr-user@lucene.apache.org
> Sent: Monday, December 15, 2008 5:28:17 PM
> Subject: Re: Standard request with functional query
> 
> Hey guys,
>     Thanks for the response, but how would make recency a factor on
> scoring documents with the standard request handler.
> The query (title:iphone OR bodytext:iphone OR title:firmware OR
> bodytext:firmware) AND _val_:"ord(dateCreated)"^0.1
> seems to do something very similar to just sorting by dateCreated
> rather than having dateCreated being a part of the score.
> 
> Thanks,
> Sammy
> 
> n Thu, Dec 4, 2008 at 1:35 PM, Sammy Yu wrote:
> > Hi guys,
> >    I have a standard query that searches across multiple text fields such as
> > q=title:iphone OR bodytext:iphone OR title:firmware OR bodytext:firmware
> >
> > This comes back with documents that have iphone and firmware (I know I
> > can use dismax handler but it seems to be really slow), which is
> > great.  Now I want to give some more weight to more recent documents
> > (there is a dateCreated field in each document).
> >
> > So I've modified the query as such:
> > (title:iphone OR bodytext:iphone OR title:firmware OR
> > bodytext:firmware) AND _val_:"ord(dateCreated)"^0.1
> > URLencoded to 
> q=(title%3Aiphone+OR+bodytext%3Aiphone+OR+title%3Afirmware+OR+bodytext%3Afirmware)+AND+_val_%3A"ord(dateCreated)"^0.1
> >
> > However, the results are not as one would expects.  The first few
> > documents only come back with the word iphone and appears to be sorted
> > by date created.  It seems to completely ignore the score and use the
> > dateCreated field for the score.
> >
> > On a not directly related issue it seems like if you put the weight
> > within the double quotes:
> > (title:iphone OR bodytext:iphone OR title:firmware OR
> > bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"
> >
> > the parser complains:
> > org.apache.lucene.queryParser.ParseException: Cannot parse
> > '(title:iphone OR bodytext:iphone OR title:firmware OR
> > bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"': Expected ',' at
> > position 16 in 'ord(dateCreated)^0.1'
> >
> > Thanks,
> > Sammy
> >


Re: Standard request with functional query

Posted by Sammy Yu <te...@gmail.com>.
Hey guys,
    Thanks for the response, but how would make recency a factor on
scoring documents with the standard request handler.
The query (title:iphone OR bodytext:iphone OR title:firmware OR
bodytext:firmware) AND _val_:"ord(dateCreated)"^0.1
seems to do something very similar to just sorting by dateCreated
rather than having dateCreated being a part of the score.

Thanks,
Sammy

n Thu, Dec 4, 2008 at 1:35 PM, Sammy Yu <te...@gmail.com> wrote:
> Hi guys,
>    I have a standard query that searches across multiple text fields such as
> q=title:iphone OR bodytext:iphone OR title:firmware OR bodytext:firmware
>
> This comes back with documents that have iphone and firmware (I know I
> can use dismax handler but it seems to be really slow), which is
> great.  Now I want to give some more weight to more recent documents
> (there is a dateCreated field in each document).
>
> So I've modified the query as such:
> (title:iphone OR bodytext:iphone OR title:firmware OR
> bodytext:firmware) AND _val_:"ord(dateCreated)"^0.1
> URLencoded to q=(title%3Aiphone+OR+bodytext%3Aiphone+OR+title%3Afirmware+OR+bodytext%3Afirmware)+AND+_val_%3A"ord(dateCreated)"^0.1
>
> However, the results are not as one would expects.  The first few
> documents only come back with the word iphone and appears to be sorted
> by date created.  It seems to completely ignore the score and use the
> dateCreated field for the score.
>
> On a not directly related issue it seems like if you put the weight
> within the double quotes:
> (title:iphone OR bodytext:iphone OR title:firmware OR
> bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"
>
> the parser complains:
> org.apache.lucene.queryParser.ParseException: Cannot parse
> '(title:iphone OR bodytext:iphone OR title:firmware OR
> bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"': Expected ',' at
> position 16 in 'ord(dateCreated)^0.1'
>
> Thanks,
> Sammy
>

Re: Standard request with functional query

Posted by Yonik Seeley <yo...@apache.org>.
On Thu, Dec 4, 2008 at 4:35 PM, Sammy Yu <te...@gmail.com> wrote:
> bodytext:firmware) AND _val_:"ord(dateCreated)^0.1"': Expected ',' at
> position 16 in 'ord(dateCreated)^0.1'

^0.1 is not function query syntax, it's Lucene/Solr QueryParser
syntax.  Try _val_:"ord(dateCreated)"^0.1

-Yonik