org.apache.lucene.search.highlight.Formatter Java Examples

The following examples show how to use org.apache.lucene.search.highlight.Formatter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LuceneQuery.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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));
}
 
Example #2
Source File: HtmlFormatter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@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>"));
}
 
Example #3
Source File: LumongoHighlighter.java    From lumongo with Apache License 2.0 4 votes vote down vote up
public LumongoHighlighter(Formatter formatter, Scorer fragmentScorer, Lumongo.HighlightRequest highlightRequest) {
	super(formatter, fragmentScorer);
	this.highlightRequest = highlightRequest;
}
 
Example #4
Source File: DefaultSolrHighlighter.java    From lucene-solr with Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: SolrFormatter.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * 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 );