Java 类org.apache.lucene.search.highlight.Formatter 实例源码

项目:lucenestudy    文件:HighlightingHelper.java   
HighlightingHelper(Query query, Analyzer analyzer) {
  this.analyzer = analyzer;

  Formatter formatter = new SimpleHTMLFormatter();
  Encoder encoder = new MinimalHTMLEncoder();
  scorer = new QueryScorer(query);
  highlighter = new Highlighter(formatter, encoder, scorer);

  fragmentLength = DEFAULT_FRAGMENT_LENGTH;
  Fragmenter fragmenter = new SimpleSpanFragmenter(scorer, fragmentLength);
  highlighter.setTextFragmenter(fragmenter);
}
项目:search    文件:DefaultSolrHighlighter.java   
/**
 * 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 );
}
项目:search    文件:HtmlFormatter.java   
@Override
public Formatter getFormatter(String fieldName, SolrParams params ) 
{
  numRequests++;
  params = SolrParams.wrapDefaults(params, defaults);

  return new SimpleHTMLFormatter(
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE,  "<em>" ), 
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
}
项目:NYBC    文件:DefaultSolrHighlighter.java   
/**
 * 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 );
}
项目:NYBC    文件:HtmlFormatter.java   
@Override
public Formatter getFormatter(String fieldName, SolrParams params ) 
{
  numRequests++;
  params = SolrParams.wrapDefaults(params, defaults);

  return new SimpleHTMLFormatter(
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE,  "<em>" ), 
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
}
项目:search-core    文件:DefaultSolrHighlighter.java   
/**
 * 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 );
}
项目:search-core    文件:HtmlFormatter.java   
@Override
public Formatter getFormatter(String fieldName, SolrParams params ) 
{
  numRequests++;
  params = SolrParams.wrapDefaults(params, defaults);

  return new SimpleHTMLFormatter(
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE,  "<em>" ), 
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
}
项目:read-open-source-code    文件:DefaultSolrHighlighter.java   
/**
 * 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 );
}
项目:read-open-source-code    文件:HtmlFormatter.java   
@Override
public Formatter getFormatter(String fieldName, SolrParams params ) 
{
  numRequests++;
  params = SolrParams.wrapDefaults(params, defaults);

  return new SimpleHTMLFormatter(
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE,  "<em>" ), 
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
}
项目:read-open-source-code    文件:DefaultSolrHighlighter.java   
/**
 * 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 );
}
项目:read-open-source-code    文件:HtmlFormatter.java   
@Override
public Formatter getFormatter(String fieldName, SolrParams params ) 
{
  numRequests++;
  params = SolrParams.wrapDefaults(params, defaults);

  return new SimpleHTMLFormatter(
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_PRE,  "<em>" ), 
      params.getFieldParam(fieldName, HighlightParams.SIMPLE_POST, "</em>"));
}
项目:bugu-mongo    文件:BuguHighlighter.java   
public void setFormatter(Formatter formatter) {
    this.formatter = formatter;
}
项目:lumongo    文件:LumongoHighlighter.java   
public LumongoHighlighter(Formatter formatter, Scorer fragmentScorer, Lumongo.HighlightRequest highlightRequest) {
    super(formatter, fragmentScorer);
    this.highlightRequest = highlightRequest;
}
项目:OCRaptor    文件:COF.java   
/**
 *
 *
 * @param query
 * @param analyzer
 * @param fieldName
 * @param fulltext
 * @param startDelimiter
 * @param stopDelimiter
 * @return
 *
 * @throws IOException
 * @throws InvalidTokenOffsetsException
 */
public static String getHighlightedField(Query query, Analyzer analyzer, String fieldName,
    String fulltext, final String startDelimiter, final String stopDelimiter) throws IOException,
        InvalidTokenOffsetsException {

  Formatter formatter = new SimpleHTMLFormatter(startDelimiter, stopDelimiter);
  QueryScorer queryScorer = new QueryScorer(query);
  Highlighter highlighter = new Highlighter(formatter, queryScorer);
  highlighter.setTextFragmenter(new SimpleSpanFragmenter(queryScorer, Integer.MAX_VALUE));
  highlighter.setMaxDocCharsToAnalyze(Integer.MAX_VALUE);

  return highlighter.getBestFragment(analyzer, fieldName, fulltext);
}
项目:community-edition-old    文件:AlfrescoSolrHighlighter.java   
/**
 * 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);
}
项目:search    文件:SolrFormatter.java   
/**
 * 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 );
项目:NYBC    文件:SolrFormatter.java   
/**
 * 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 );
项目:search-core    文件:SolrFormatter.java   
/**
 * 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 );
项目:read-open-source-code    文件:SolrFormatter.java   
/**
 * 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 );
项目:read-open-source-code    文件:SolrFormatter.java   
/**
 * 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 );