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-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to