FAQ
I'm trying to implement highlighting in my lucene application and I can't
get any fragment. getBestFragment always returns null.

My code:

QueryParser parser = new QueryParser(Version.LUCENE_30, "text",
myAnalyzer);
Query realQuery = parser.parse(query);

Highlighter highlighter = new Highlighter(new QueryScorer(realQuery,
"text"));
for (ScoreDoc scoredoc : luceneTopDocs.scoreDocs ) {
Document doc = null;
doc = searcher.doc(scoredoc.doc);
String bestFragment = highlighter.getBestFragment(myAnalyzer,
"text", doc.get("text"));
if (bestFragment != null) doSomething();
}

Thank you,
Diego

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedMay 21, '10 at 11:31a
activeMay 21, '10 at 11:31a
posts1
users1
websitelucene.apache.org

1 user in discussion

Diego Campoy: 1 post

People

Translate

site design / logo © 2022 Grokbase