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 sangrish <si...@gmail.com> on 2011/11/03 23:10:36 UTC

Access Score in Custom Function Query


Hi,


  I have a custom function query (value source) where I want to use the
score for some computation. For example, for every document I want to add
some number (obtained from an external file) to its score. I am achieving
this like the following:

http://localhost:PORT/myCore/select?q=queryString&qt=my_request_handler&fl=field1,field2,score&debugQuery=on&sort=myfunc(query$(qq))
desc

Where, definition of "my_request_handler" & "qq" are as follows:

<requestHandler name="my_request_handler" class="solr.SearchHandler">
        <lst name="defaults">
            <str name="qq">{!dismax v=$q}</str>
            
            <str name="qf">
                field1^2 field^3
            </str>
</requestHandler>

Questions:

1. To obtain the score in my function query I am executing the dismax query
again ( myfunc( query($qq)). Could it slow things down? Is there any way I
can access the score without querying again?
2. I also want to normalize the (query) score I get to a range between 0 -
1. Is there any way to access the MAX_SCORE in the same function query/Value
source (so that I can divide every score by that)?


Thanks lot guys

Sid




--
View this message in context: http://lucene.472066.n3.nabble.com/Access-Score-in-Custom-Function-Query-tp3478597p3478597.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Access Score in Custom Function Query

Posted by Erick Erickson <er...@gmail.com>.
First, have you looked at External File Fields as a way of accessing
the external info?

As for the rest, you'd probably have to write a custom handler to put that
data in the response packets.... Although the score of the first document
in the list is the max-score by definition, assuming you're sorting by score.
And you can always get score back as a field in the docs....

Best
Erick

On Thu, Nov 3, 2011 at 6:10 PM, sangrish <si...@gmail.com> wrote:
>
>
> Hi,
>
>
>  I have a custom function query (value source) where I want to use the
> score for some computation. For example, for every document I want to add
> some number (obtained from an external file) to its score. I am achieving
> this like the following:
>
> http://localhost:PORT/myCore/select?q=queryString&qt=my_request_handler&fl=field1,field2,score&debugQuery=on&sort=myfunc(query$(qq))
> desc
>
> Where, definition of "my_request_handler" & "qq" are as follows:
>
> <requestHandler name="my_request_handler" class="solr.SearchHandler">
>        <lst name="defaults">
>            <str name="qq">{!dismax v=$q}</str>
>
>            <str name="qf">
>                field1^2 field^3
>            </str>
> </requestHandler>
>
> Questions:
>
> 1. To obtain the score in my function query I am executing the dismax query
> again ( myfunc( query($qq)). Could it slow things down? Is there any way I
> can access the score without querying again?
> 2. I also want to normalize the (query) score I get to a range between 0 -
> 1. Is there any way to access the MAX_SCORE in the same function query/Value
> source (so that I can divide every score by that)?
>
>
> Thanks lot guys
>
> Sid
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Access-Score-in-Custom-Function-Query-tp3478597p3478597.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>