Class CustomPassageFormatter


  • public class CustomPassageFormatter
    extends PassageFormatter
    Custom passage formatter that allows us to: 1) extract different snippets (instead of a single big string) together with their scores (Snippet) 2) use the Encoder implementations that are already used with the other highlighters
    • Constructor Detail

      • CustomPassageFormatter

        public CustomPassageFormatter​(String preTag,
                                      String postTag,
                                      Encoder encoder)
    • Method Detail

      • format

        public Snippet[] format​(Passage[] passages,
                                String content)
        Description copied from class: PassageFormatter
        Formats the top passages from content into a human-readable text snippet.
        Specified by:
        format in class PassageFormatter
        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. Note that for the non-expert APIs in UnifiedHighlighter that return String, the toString method on the Object returned by this method is used to compute the string.