If I have a fullText field with these contents
In 2014 and 2015 the results were ... [more] ... and Sony are developing ... [more]
And query for
+loadTime:[2014 TO 2015] +fullText:sony
The Highlighter is picking 2014 and 2015 as the best fragment. How do I get the highlighter to ignore matches from the loadTime part of the query and use matches from the fullText part of the search? I want to see the ... sony ... fragment, even if it scores lower than the date parts that (just happened) to match the fullText.
My code:
ScoreDoc[] hits = [create search];
IFormatter formatter = new SimpleHTMLFormatter("<b>", "</b>");
QueryScorer scorer = new QueryScorer(query, );
Highlighter highlighter = new Highlighter(formatter, scorer);
for (int i = 0; i < hits.Length; i++)
{
int docId = hits[i].Doc;
float score = hits[i].Score;
Document doc = search.Doc(docId);
string fragments = string.Empty;
if (collectFragments)
{
TokenStream stream = _analyzer.TokenStream("", new StringReader(doc.Get(AppConstants.Fields.FullText)));
fragments = highlighter.GetBestFragments(stream, doc.Get(AppConstants.Fields.FullText), 2, "...");
}
...
}