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 Christopher Gross <co...@gmail.com> on 2012/01/05 21:31:38 UTC

Solr Scoring question

I'm getting different results running these queries:

http://localhost:8080/solr/select?&q=*:*&fq=source:wiki&fq=tag:car&sort=score+desc,dateSubmitted+asc&fl=title,score,dateSubmitted&rows=100

http://localhost:8080/solr/select?fq=source:wiki&q=tag:car&sort=score+desc,dateSubmitted+desc&fl=title,score,dateSubmitted&rows=100

They return the same amount of results (and I'm assuming the same
ones) -- but the first one (with q=*:*) has a score of 1 for all
results, making it only sort by dateSubmitted.  The second one has
scores, and it properly sorts them.

I was thinking that the two would be equivalent and give the same
results in the same order, but I'm guessing that there is something
happening behind the scenes in Solr (Lucene?) that makes the *:* give
me a score of 1.0 for everything.  I tried to find some documentation
to figure out if this is the case, but I'm not having much luck for
that.

I have a JSP file that will take in parameters, do some work on them
to make them appropriate for Solr, then pass the query it builds to
Solr.  Should I just put more brains in that to avoid using a *:*
(we're trying to verify results and we ran into this oddity).

This is for Solr 3.4, running Tomcat 5.5.25 on Java 1.5.

Thanks!  Let me know if Ineed to clarify anything...

-- Chris

Re: Solr Scoring question

Posted by Esteban Donato <es...@gmail.com>.
filter queries (fq) are not included for score calculation, just the
query in q parameter is used for this purpose.  That's why although
you get the same results, lucene will just use q=*:* in your 1st query
and q=tag:car in your 2nd query to calculate the scores.  As you can
see since both queries are different you should expect different
scores.

If you want the details about how the score is calculated for each
doc, append debugQuery=true to your Solr's query string and check the
"explain" section

On Thu, Jan 5, 2012 at 6:16 PM, Simon Willnauer
<si...@googlemail.com> wrote:
> hey,
>
> On Thu, Jan 5, 2012 at 9:31 PM, Christopher Gross <co...@gmail.com> wrote:
>> I'm getting different results running these queries:
>>
>> http://localhost:8080/solr/select?&q=*:*&fq=source:wiki&fq=tag:car&sort=score+desc,dateSubmitted+asc&fl=title,score,dateSubmitted&rows=100
>>
>> http://localhost:8080/solr/select?fq=source:wiki&q=tag:car&sort=score+desc,dateSubmitted+desc&fl=title,score,dateSubmitted&rows=100
>>
>> They return the same amount of results (and I'm assuming the same
>> ones) -- but the first one (with q=*:*) has a score of 1 for all
>> results, making it only sort by dateSubmitted.  The second one has
>> scores, and it properly sorts them.
>>
>> I was thinking that the two would be equivalent and give the same
>> results in the same order, but I'm guessing that there is something
>> happening behind the scenes in Solr (Lucene?) that makes the *:* give
>> me a score of 1.0 for everything.  I tried to find some documentation
>> to figure out if this is the case, but I'm not having much luck for
>> that.
>
> q=*:* is a constant score query that retireves all documents in your
> index. The issue here is that with *:* you don't have anything to
> score while with q=tag:car you can score the term car with tf idf etc.
>
> does that make sense?
>
> simon
>>
>> I have a JSP file that will take in parameters, do some work on them
>> to make them appropriate for Solr, then pass the query it builds to
>> Solr.  Should I just put more brains in that to avoid using a *:*
>> (we're trying to verify results and we ran into this oddity).
>>
>> This is for Solr 3.4, running Tomcat 5.5.25 on Java 1.5.
>>
>> Thanks!  Let me know if Ineed to clarify anything...
>>
>> -- Chris

Re: Solr Scoring question

Posted by Simon Willnauer <si...@googlemail.com>.
hey,

On Thu, Jan 5, 2012 at 9:31 PM, Christopher Gross <co...@gmail.com> wrote:
> I'm getting different results running these queries:
>
> http://localhost:8080/solr/select?&q=*:*&fq=source:wiki&fq=tag:car&sort=score+desc,dateSubmitted+asc&fl=title,score,dateSubmitted&rows=100
>
> http://localhost:8080/solr/select?fq=source:wiki&q=tag:car&sort=score+desc,dateSubmitted+desc&fl=title,score,dateSubmitted&rows=100
>
> They return the same amount of results (and I'm assuming the same
> ones) -- but the first one (with q=*:*) has a score of 1 for all
> results, making it only sort by dateSubmitted.  The second one has
> scores, and it properly sorts them.
>
> I was thinking that the two would be equivalent and give the same
> results in the same order, but I'm guessing that there is something
> happening behind the scenes in Solr (Lucene?) that makes the *:* give
> me a score of 1.0 for everything.  I tried to find some documentation
> to figure out if this is the case, but I'm not having much luck for
> that.

q=*:* is a constant score query that retireves all documents in your
index. The issue here is that with *:* you don't have anything to
score while with q=tag:car you can score the term car with tf idf etc.

does that make sense?

simon
>
> I have a JSP file that will take in parameters, do some work on them
> to make them appropriate for Solr, then pass the query it builds to
> Solr.  Should I just put more brains in that to avoid using a *:*
> (we're trying to verify results and we ran into this oddity).
>
> This is for Solr 3.4, running Tomcat 5.5.25 on Java 1.5.
>
> Thanks!  Let me know if Ineed to clarify anything...
>
> -- Chris