tags:

views:

175

answers:

2

Hi,

I'm trying to read document score of lucene search results.

I get a set of document scores through the hits object when I use the following method : Hits hits = IndexSearcher.search(myQuery);

However,if i use the method: searcher.search(myQuery, hitsCollector);

I get a totally different set of document scores through the hitCollector.hits object

Am I missing something here?

Thanks!

+1  A: 

The scores returned by a Hits object are normalized, i.e. they are always in the range [0, 1], with the highest score close to or at 1. The scores given to a HitCollector object are raw, i.e. not normalized. Also, the list of documents in a Hits object is sorted by decreasing scores. A HitCollector object gets document-score pairs in some random order.

Kai Chan
A: 

thanks for your response.

Using Hits object,I used to multiply the score by 100 and show it in the results....ie 0.97 * 100=97%, 56.2 * 100=56% etc...

I need to use HitsCollector object for search because i need to "Group" the search results by various fields.

Since HitsCollector object normalizes the score,after multiplying this score by 100, am getting values like 320%,290% etc...and user would like to see if the search result score in the range of 0-100 %

How do i resolve this?

Thanks again