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 Liu <li...@duokan.com> on 2013/08/20 11:53:03 UTC

How to sort by the function: relevance_score*numberic_field/(relevance_score +numberic_field )

Hi:

  I want to rank the search result by the function:
relevance_score*numberic_field/(relevance_score +numberic_field ) , this
function equals to 

1/((1/relevance_score)+1/numberic_field) 

 

As far as I know ,I could use function query: sort=
div(1,sum(div(1,field(numberic_field)),div(1,query({!edismax v='
somewords''})))) .There is a subquery in this function: query({!edismax
v='somewords'}) ,it returns the relevance_sore .But I can't figure out its
query efficiency. After tracking the source code, I think the efficiency is
OK, but I can't make sure.

 

Do we have other approaches to sort docs by:
relevance_score*numberic_field/(relevance_score +numberic_field ) ?

 

Thank you

Leo


Re: How to sort by the function: relevance_score*numberic_field/(relevance_score +numberic_field )

Posted by Chris Hostetter <ho...@fucit.org>.
:   I want to rank the search result by the function:
: relevance_score*numberic_field/(relevance_score +numberic_field ) , this
: function equals to 
: 
: 1/((1/relevance_score)+1/numberic_field) 

your email seems to asks 2 differnet questions:

1) "sort by the function ...(containing the relevancy score)"

2) "rank (ie: score) the search result by the function"

You can do 1 or hte other or both -- but it's important to understand the 
differnce...

1) you can structure your "main" query such that the *score* produced for 
each document is computed by a function where an input to that function is 
the result of a "sub query"  This might be something like...

  ?q={!boost f=numberic_field v=$qq}
  &qq={!edismax ....}

...this will affect the value of the "score" returned for each document, 
as well as the behavior if you sort by "score"

Because i used the "boost" parser explicitly in this example, the function 
doesn't affect which documents match, it just computes the scores of the 
documents matching the subquery by multipling their originla score by the 
function.


2) independent of your main query, you can sort by an arbitrary function, 
where an input to that function is the result of some query.  This might 
be something like your specific example...

  ?q=...whatever you want...
  sort=div(1,sum(div(1,field(numberic_field)),div(1,$qq) desc
  qq={!edismax ...}

...this will affect the order that documents are returned, but won't 
affect the "score" returned with each document.  It also won't affect 
which documents match, it just computes an independent numeric value for 
sorting hte documents that already match.

3) you can combine #1 and #2 if you want to -- they can be based on 
different relevancy queries, or even the exact same relevancy query using 
variable replacement if that's what you want -- but you can't refer to 
"score" as the input of a function query because it doesn't know which 
"score" you want to use (you could have lots of different queries with 
differnet scores being computed as part of the request)...



-Hoss

Re: How to sort by the function: relevance_score*numberic_field/(relevance_score +numberic_field )

Posted by Jack Krupansky <ja...@basetechnology.com>.
Solr does not have a function query value source which is the raw document 
relevance score for the current query.

That would be a nice Jira request.

Or, a parameter to outright replace the score for each document rather than 
merely multiply or add to it.

-- Jack Krupansky

-----Original Message----- 
From: Liu
Sent: Tuesday, August 20, 2013 5:53 AM
To: solr-user@lucene.apache.org
Subject: How to sort by the function: 
relevance_score*numberic_field/(relevance_score +numberic_field )

Hi:

  I want to rank the search result by the function:
relevance_score*numberic_field/(relevance_score +numberic_field ) , this
function equals to

1/((1/relevance_score)+1/numberic_field)



As far as I know ,I could use function query: sort=
div(1,sum(div(1,field(numberic_field)),div(1,query({!edismax v='
somewords''})))) .There is a subquery in this function: query({!edismax
v='somewords'}) ,it returns the relevance_sore .But I can't figure out its
query efficiency. After tracking the source code, I think the efficiency is
OK, but I can't make sure.



Do we have other approaches to sort docs by:
relevance_score*numberic_field/(relevance_score +numberic_field ) ?



Thank you

Leo