Ability to project Lucene meta information (Score, Boost, Document, Id, This) (John Griffin)

Description

I need the score of a hit. The only time when this information is available seems to be in FullTextQueryImpl.java in line 219:

for ( int index = first; index <= max; index++ ) {
Document document = hits.doc( index );
infos.add( extractor.extract( document ) );
}

Not sure what the API would look like and what other information from each Hit object would be considered metadata, except the score and maybe boost. Maybe this can be covered with magic projection properties, something like:

org.hibernate.search.FullTextQuery query = s.createFullTextQuery( luceneQuery, Book.class );
query.setIndexProjection( "hsearchScore", "this" );
List results = query.list();
Object[] firstResult = (Object[]) results.get(0);
Double score = firstResult[0];
Book book = firstResult[1];

Activity

Emmanuel BernardJuly 25, 2007 at 5:53 PM

Not yet open a new JIRA issue please. It make sense to provide the top score somehow

Fabien MichonJuly 25, 2007 at 10:55 AM

Is there a solution to normalize the score ?

For example if we want to display the score un percents ...

(http://jsourcery.com/api/apache/lucene/2.0.0/org/apache/lucene/search/TopDocs.html)

Emmanuel BernardJune 20, 2007 at 12:15 AM

John is on it

Christian BauerJune 6, 2007 at 3:44 PM

Or simply return FullTextQuery.LUCENE_HIT

Christian BauerJune 6, 2007 at 9:17 AM

I think this is actually the best and easiest solution and quite OK if you use constants:

FullTextQuery query = s.createFullTextQuery( luceneQuery, Book.class );
query.setIndexProjection( FullTextQuery.SCORE, FullTextQuery.BOOST, FullTextQuery.DOCUMENT, FullTextQuery.THIS );

Maybe setIndexProjection() needs to be renamed to setProjection()

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Created June 6, 2007 at 9:12 AM
Updated November 13, 2008 at 6:08 PM
Resolved July 21, 2007 at 2:16 AM