lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Confidence scores at search time
Date Mon, 02 Mar 2009 19:58:56 GMT

On Mar 2, 2009, at 2:47 PM, Ken Williams wrote:
> Finally, I seem unable to get Searcher.explain() to do much useful -  
> my code
> looks like:
>
>        Searcher searcher = new IndexSearcher(reader);
>        QueryParser parser = new QueryParser(LuceneIndex.CONTENT,  
> analyzer);
>        Query query = parser.parse(queryString);
>        TopDocCollector collector = new TopDocCollector(n);
>        searcher.search(query, collector);
>
>        for ( ScoreDoc d : collector.topDocs().scoreDocs ) {
>            String explanation = searcher.explain(query,  
> d.doc).toString();
>            Field id =  
> searcher.doc( d.doc ).getField( LuceneIndex.ID );
>            System.out.println(id + "\t" + d.score + "\t" +  
> explanation);
>        }
>
> In the output, I get explanations like "0.88922405 = (MATCH) product  
> of:"
> with no details.  Perhaps I need to do something different in  
> indexing?

Explanation.toString() only returns the first line.  You can use  
toString(int depth) or loop over all the getDetails().   toHtml()  
returns a decently formatted tree of <ul>'s of the whole explanation  
also.

	Erik


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


Mime
View raw message