I've made a search component in my application with lucene. everything works fine, Indexing, highlighting ,etc. I need now to return a paragraph as my search response and not just limit the result to "fragmentSize" in SimpleSpanFragmenter method.there is part of my code:
SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class='highlight'>", "</span>");
QueryScorer scorer = new QueryScorer(query, NodeDocument.TEXT_FIELD);
Highlighter highlighter = new Highlighter(formatter, scorer);
highlighter.setTextFragmenter(new SimpleSpanFragmenter(scorer, MAX_FRAGMENT_LEN));
String excerpt = highlighter.getBestFragment(analyzer, Document.MESSAGE_FIELD, nForumPost.getMessage());
This code returns "MAX_FRAGMENT_LEN" which I've set to 256. but its not my ideal. I want to get a paragraph which contains my search word in query.