You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by lucene_user <jk...@cs.tufts.edu> on 2007/10/10 18:44:52 UTC

Scoring a single document from a corpus based on a given query

I would like to score a single document from a corpus based on a given query. 
The formula score(q,d) is basically what I am looking for.

Pseudo Code of Something Close to what I am looking for:
indexReader.score(query, documentId);

The formula score(q,d) is used throughout the documentation to describe
similarity but there does not seem to be a corresponding java method.

I could work around the issue by applying a search filter to only consider
the particular document I am looking for.  I was hoping for a cleaner
approach. 
-- 
View this message in context: http://www.nabble.com/Scoring-a-single-document-from-a-corpus-based-on-a-given-query-tf4601980.html#a13139648
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Scoring a single document from a corpus based on a given query

Posted by Yonik Seeley <yo...@apache.org>.
On 10/10/07, Grant Ingersoll <gs...@apache.org> wrote:
> Have a look at the contrib/memory package delivered with Lucene.  It
> contains a MemoryIndex which is designed exactly for this scenario.

That's a fast way to see if a single doc matches a query, but it won't
give you the same score as if you queried the complete corpus (idf
factors, etc).

-Yonik

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Scoring a single document from a corpus based on a given query

Posted by Grant Ingersoll <gs...@apache.org>.
Have a look at the contrib/memory package delivered with Lucene.  It  
contains a MemoryIndex which is designed exactly for this scenario.

On Oct 10, 2007, at 12:44 PM, lucene_user wrote:

>
> I would like to score a single document from a corpus based on a  
> given query.
> The formula score(q,d) is basically what I am looking for.
>
> Pseudo Code of Something Close to what I am looking for:
> indexReader.score(query, documentId);
>
> The formula score(q,d) is used throughout the documentation to  
> describe
> similarity but there does not seem to be a corresponding java method.
>
> I could work around the issue by applying a search filter to only  
> consider
> the particular document I am looking for.  I was hoping for a cleaner
> approach.
> -- 
> View this message in context: http://www.nabble.com/Scoring-a- 
> single-document-from-a-corpus-based-on-a-given-query- 
> tf4601980.html#a13139648
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

--------------------------
Grant Ingersoll
http://lucene.grantingersoll.com

Lucene Boot Camp Training:
ApacheCon Atlanta, Nov. 12, 2007.  Sign up now!  http:// 
www.apachecon.com

Lucene Helpful Hints:
http://wiki.apache.org/lucene-java/BasicsOfPerformance
http://wiki.apache.org/lucene-java/LuceneFAQ



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Scoring a single document from a corpus based on a given query

Posted by lucene_user <jk...@cs.tufts.edu>.
The Scorer.explain() method worked.

Thanks for the replies.  I may be able to use MemoryIndex in a different
situation.


Paul Elschot wrote:
> 
> On Wednesday 10 October 2007 18:44, lucene_user wrote:
>> I would like to score a single document from a corpus based on a given
>> query. The formula score(q,d) is basically what I am looking for.
>>
>> Pseudo Code of Something Close to what I am looking for:
>> indexReader.score(query, documentId);
>>
>> The formula score(q,d) is used throughout the documentation to describe
>> similarity but there does not seem to be a corresponding java method.
>>
>> I could work around the issue by applying a search filter to only
>> consider
>> the particular document I am looking for.  I was hoping for a cleaner
>> approach.
> 
> You can try this:
> 
> Explanation e = indexSearcher.explain(query, documentId);
> 
> and get the score value from the explanation.
> 
> Have a look at the code of any Scorer.explain() method on
> how to get the score value only. There really is no need to filter
> in this case.
> 
> Regards,
> Paul Elschot
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Scoring-a-single-document-from-a-corpus-based-on-a-given-query-tf4601980.html#a13176984
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Scoring a single document from a corpus based on a given query

Posted by Paul Elschot <pa...@xs4all.nl>.
On Wednesday 10 October 2007 18:44, lucene_user wrote:
> I would like to score a single document from a corpus based on a given
> query. The formula score(q,d) is basically what I am looking for.
>
> Pseudo Code of Something Close to what I am looking for:
> indexReader.score(query, documentId);
>
> The formula score(q,d) is used throughout the documentation to describe
> similarity but there does not seem to be a corresponding java method.
>
> I could work around the issue by applying a search filter to only consider
> the particular document I am looking for.  I was hoping for a cleaner
> approach.

You can try this:

Explanation e = indexSearcher.explain(query, documentId);

and get the score value from the explanation.

Have a look at the code of any Scorer.explain() method on
how to get the score value only. There really is no need to filter
in this case.

Regards,
Paul Elschot

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org