Can anyone tell me if there is a way to highlight a phrase with a single highlight using the lucene .net QueryParser?
For Eg I have the text:- The quick fox jumped over the wall.
I search for: "Quick fox" The highlights returned by lucene.net
The <>quick<> <>fox<> jumped over the wall.
QueryParser parser = new QueryParser(Version.LUCENE_30, "DocumentText", this.analyzer);
Query query;
query = parser.Parse(searchTerm);
QueryScorer scorer = new QueryScorer(query);
IFormatter formatter = new SimpleHTMLFormatter("<>", "<>");
SimpleFragmenter fragmenter = new SimpleFragmenter(int.MaxValue - 1);
Highlighter highlighter = new Highlighter(formatter, scorer);
highlighter.TextFragmenter = fragmenter;
highlighter.MaxDocCharsToAnalyze = int.MaxValue;
StringBuilder hitHighlights = new StringBuilder();
this.stream = this.analyzer.TokenStream(string.Empty, this.documentStringReader);
string highlights = highlighter.GetBestFragments(this.stream, documentTextChunk, 0, ".");
Is there a way to return a single tag around the phrase Eg:-
The <>quick fox<> jumped over the wall.
Thanks, Vineet