org.apache.lucene.search.postingshighlight
Class PassageFormatter

java.lang.Object
  extended by org.apache.lucene.search.postingshighlight.PassageFormatter

public class PassageFormatter
extends Object

Creates a formatted snippet from the top passages.

The default implementation marks the query terms as bold, and places ellipses between unconnected passages.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Constructor Summary
PassageFormatter()
          Creates a new PassageFormatter with the default tags.
PassageFormatter(String preTag, String postTag, String ellipsis)
          Creates a new PassageFormatter with custom tags.
 
Method Summary
 String format(Passage[] passages, String content)
          Formats the top passages from content into a human-readable text snippet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PassageFormatter

public PassageFormatter()
Creates a new PassageFormatter with the default tags.


PassageFormatter

public PassageFormatter(String preTag,
                        String postTag,
                        String ellipsis)
Creates a new PassageFormatter with custom tags.

Parameters:
preTag - text which should appear before a highlighted term.
postTag - text which should appear after a highlighted term.
ellipsis - text which should be used to connect two unconnected passages.
Method Detail

format

public String format(Passage[] passages,
                     String content)
Formats the top passages from content into a human-readable text snippet.

Parameters:
passages - top-N passages for the field. Note these are sorted in the order that they appear in the document for convenience.
content - content for the field.
Returns:
formatted highlight


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.