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

The following examples show how to use org.apache.lucene.search.highlight.Formatter. These examples are extracted from open source projects. 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 Project: rdf4j   Source File: LuceneQuery.java    License: 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 Project: lucene-solr   Source File: HtmlFormatter.java    License: 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 Project: lumongo   Source File: LumongoHighlighter.java    License: 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 Project: lucene-solr   Source File: DefaultSolrHighlighter.java    License: 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 Project: lucene-solr   Source File: SolrFormatter.java    License: 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 );