You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "Woolf, Ross" <Ro...@BMC.com> on 2010/02/25 00:40:07 UTC

Not getting any highlighter results when using wildcards

When I use a WildcardQuery with the highlighter, I don't get any fragments back, I get null returned to strBetText.  If I just use a term query then it works.  

TokenStream tokenStream = TokenSources.getTokenStream(indexReader, docId, strFieldName);
QueryScorer scorer = new QueryScorer(query, strFieldName);
Fragmenter fragmenter = new SimpleSpanFragmenter(scorer);
SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("[", "]");
Highlighter highlighter = new Highlighter(formatter, scorer);
highlighter.setTextFragmenter(fragmenter);
String strBestText = null;
strBestText = highlighter.getBestFragment(tokenStream, strText);

In the Lucene In Action book it mentions that if you are using wildcard that you need to call rewrite on query before using it.  I have tried doing this but in my debugger I still see the query with the wildcard and it does not look as if it has rewritten it.  

Is there a problem using wildcards in the highlighter, or am I not using rewrite on my query correctly? (why would code inside the highlighter not call the rewrite automatically?).  

Any help would be appreciated.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org