lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cescy" <ee07b...@gmail.com>
Subject About highlighter
Date Tue, 15 Mar 2011 20:47:14 GMT
Hi, 


My highlight code is shown as following:


  QueryScorer scorer = new QueryScorer(query);
  Highlighter highlighter = new Highlighter(simpleHTMLFormatter, scorer);
  highlighter.setTextFragmenter(new SimpleSpanFragmenter(scorer, 500));
  String contents = doc.get("contents");
  TokenStream tokenStream = TokenSources.getAnyTokenStream(searcher.getIndexReader(), topDocs.scoreDocs[i].doc,
"contents", doc, analyzer);
  String[] snippet = highlighter.getBestFragments(tokenStream, contents, 10);



snippet is the result contexts and then I will print out them on the screen.
But If I may search for a keyword at the last few paragraph and the essay is too long (1000-2000
words), it will return "document found" and snippet.length=0 (i.e. document is found but context
is NOT found). Why???


How could I fix the problem?
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message