下面列出了怎么用org.apache.lucene.search.highlight.Formatter的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
@Deprecated
public void highlight(IRI property) {
Formatter formatter = new SimpleHTMLFormatter(SearchFields.HIGHLIGHTER_PRE_TAG,
SearchFields.HIGHLIGHTER_POST_TAG);
highlighter = new Highlighter(formatter, new QueryScorer(query));
}
@Override
public Formatter getFormatter(String fieldName, SolrParams params )
{
numRequests.inc();
params = SolrParams.wrapDefaults(params, defaults);
return new SimpleHTMLFormatter(
params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE, "<em>" ),
params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
}
public LumongoHighlighter(Formatter formatter, Scorer fragmentScorer, Lumongo.HighlightRequest highlightRequest) {
super(formatter, fragmentScorer);
this.highlightRequest = highlightRequest;
}
/**
* Return a {@link org.apache.lucene.search.highlight.Formatter} appropriate for this field. If a formatter
* has not been configured for this field, fall back to the configured
* default or the solr default ({@link org.apache.lucene.search.highlight.SimpleHTMLFormatter}).
*
* @param fieldName The name of the field
* @param params The params controlling Highlighting
* @return An appropriate {@link org.apache.lucene.search.highlight.Formatter}.
*/
protected Formatter getFormatter(String fieldName, SolrParams params) {
String str = params.getFieldParam(fieldName, HighlightParams.FORMATTER);
SolrFormatter formatter = formatters.get(str);
if (formatter == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown formatter: " + str);
}
return formatter.getFormatter(fieldName, params);
}
/**
* Return a {@link org.apache.lucene.search.highlight.Formatter} appropriate for this field.
*
* @param fieldName The name of the field
* @param params The params controlling Highlighting
* @return An appropriate {@link org.apache.lucene.search.highlight.Formatter}
*/
public Formatter getFormatter(String fieldName, SolrParams params );