lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stelios Eliakis" <>
Subject highlighting
Date Sat, 23 Sep 2006 09:39:27 GMT
I'm new to lucene and I'm interesting in highlighting.
I want to extract the Best Fragment (passage) from a text file.
When I use the following code I take the first fragment that contains my
query. Nevertheless, the JavaDoc says that the function getBestFragment
returns the best fragment. Do I something wrong?

    QueryScorer scorer = new QueryScorer(query);

    SimpleHTMLFormatter formatter =new SimpleHTMLFormatter("<span

    Highlighter highlighter = new Highlighter(formatter, scorer);

    Fragmenter fragmenter = new SimpleFragmenter(50);

    QueryScorer fragmentScore=(QueryScorer) highlighter.getFragmentScorer();

    TokenStream tokenStream = new StandardAnalyzer().tokenStream("contents",
new StringReader(text));

    String result = highlighter.getBestFragment(tokenStream,text);


Thanks in advance

Stelios Eliakis

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