lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diego Campoy <dcam...@salir.com>
Subject Highlighter in lucene doesn't return any fragment
Date Fri, 21 May 2010 11:30:39 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message