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 Scott Smith <ss...@mainstreamdata.com> on 2013/11/27 01:19:18 UTC
Phrase highlight
I'm doing some highlighting with the following code fragment:
formatter = new SimpleHTMLFormatter(<b>,
</b>);
Scorer score = new QueryScorer(myQuery);
ht = new Highlighter(formatter, score);
ht.setTextFragmenter(new NullFragmenter());
markedString = ht.getBestFragment(ctf, myText);
However, if myQuery has a phrase like "john smith", then it will highlight "john" every place it sees it and "smith" everyplace it sees it regardless of whether they are together. Is this expected behavior? Is there any way to get phrases to be properly highlighted?
Re: Phrase highlight
Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
(13/11/27 9:19), Scott Smith wrote:
> I'm doing some highlighting with the following code fragment:
>
> formatter = new SimpleHTMLFormatter(<b>,
> </b>);
> Scorer score = new QueryScorer(myQuery);
> ht = new Highlighter(formatter, score);
> ht.setTextFragmenter(new NullFragmenter());
> markedString = ht.getBestFragment(ctf, myText);
>
>
> However, if myQuery has a phrase like "john smith", then it will highlight "john" every place it sees it and "smith" everyplace it sees it regardless of whether they are together. Is this expected behavior? Is there any way to get phrases to be properly highlighted?
>
Consult getPhraseHighlighter() in DefaultSolrHighlighter.java of Solr and its caller:
protected Highlighter getPhraseHighlighter(Query query, String fieldName, SolrQueryRequest
request, CachingTokenFilter tokenStream) throws IOException {
SolrParams params = request.getParams();
Highlighter highlighter = null;
highlighter = new Highlighter(
getFormatter(fieldName, params),
getEncoder(fieldName, params),
getSpanQueryScorer(query, fieldName, tokenStream, request));
highlighter.setTextFragmenter(getFragmenter(fieldName, params));
return highlighter;
}
koji
--
http://soleami.com/blog/automatically-acquiring-synonym-knowledge-from-wikipedia.html
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org