Highlighter.net returns no matches

74 Views Asked by At

I am using lucene.net 2.9.4 and lucene.net contrib 2.9.4 my lucene query looks like:

+contents:umbraco*

I get results for this query. My highlighter code to get fragments looks like:

public string GetHighlight(string value, string highlightField, IndexSearcher searcher, string luceneRawQuery)
    {
        var query = GetQueryParser(highlightField).Parse(luceneRawQuery);

        var scorer = new QueryScorer(searcher.Rewrite(query));

        var highlighter = new Highlighter(HighlightFormatter, scorer);

        var tokenStream = HighlightAnalyzer.TokenStream(highlightField, new StringReader(value));

        return highlighter.GetBestFragments(tokenStream, value, MaxNumHighlights, Separator);
    }

In my scorer object the property termsToFind is 0 I would expect that to at least be one? Anyone any ideas or suggestions on how to fix / debug?

Regards

Ismail

1

There are 1 best solutions below

0
On

Ok figured this out I was passing in the wrong values to the highlighter function. I was passing the query search term and field name. What i needed to pass in was the content of the contents field for each document match and the query term. All working now.