Class HighlightBuilder

    • Field Detail

      • DEFAULT_FORCE_SOURCE

        public static final boolean DEFAULT_FORCE_SOURCE
        default for whether to highlight fields based on the source even if stored separately
        See Also:
        Constant Field Values
      • DEFAULT_REQUIRE_FIELD_MATCH

        public static final boolean DEFAULT_REQUIRE_FIELD_MATCH
        default for whether a field should be highlighted only if a query matches that field
        See Also:
        Constant Field Values
      • DEFAULT_HIGHLIGHT_FILTER

        public static final boolean DEFAULT_HIGHLIGHT_FILTER
        default for whether fvh should provide highlighting on filter clauses
        See Also:
        Constant Field Values
      • DEFAULT_SCORE_ORDERED

        public static final boolean DEFAULT_SCORE_ORDERED
        default for highlight fragments being ordered by score
        See Also:
        Constant Field Values
      • DEFAULT_ENCODER

        public static final java.lang.String DEFAULT_ENCODER
        the default encoder setting
        See Also:
        Constant Field Values
      • DEFAULT_PHRASE_LIMIT

        public static final int DEFAULT_PHRASE_LIMIT
        default for the maximum number of phrases the fvh will consider
        See Also:
        Constant Field Values
      • DEFAULT_NO_MATCH_SIZE

        public static final int DEFAULT_NO_MATCH_SIZE
        default for fragment size when there are no matches
        See Also:
        Constant Field Values
      • DEFAULT_NUMBER_OF_FRAGMENTS

        public static final int DEFAULT_NUMBER_OF_FRAGMENTS
        the default number of fragments for highlighting
        See Also:
        Constant Field Values
      • DEFAULT_FRAGMENT_CHAR_SIZE

        public static final int DEFAULT_FRAGMENT_CHAR_SIZE
        the default number of fragments size in characters
        See Also:
        Constant Field Values
      • DEFAULT_STYLED_PRE_TAG

        public static final java.lang.String[] DEFAULT_STYLED_PRE_TAG
        the default opening tags when tag_schema = "styled"
      • DEFAULT_STYLED_POST_TAGS

        public static final java.lang.String[] DEFAULT_STYLED_POST_TAGS
        the default closing tags when tag_schema = "styled"
    • Constructor Detail

      • HighlightBuilder

        public HighlightBuilder()
      • HighlightBuilder

        public HighlightBuilder​(StreamInput in)
                         throws java.io.IOException
        Read from a stream.
        Throws:
        java.io.IOException
    • Method Detail

      • field

        public HighlightBuilder field​(java.lang.String name)
        Adds a field to be highlighted with default fragment size of 100 characters, and default number of fragments of 5 using the default encoder
        Parameters:
        name - The field to highlight
      • field

        public HighlightBuilder field​(java.lang.String name,
                                      int fragmentSize)
        Adds a field to be highlighted with a provided fragment size (in characters), and default number of fragments of 5.
        Parameters:
        name - The field to highlight
        fragmentSize - The size of a fragment in characters
      • field

        public HighlightBuilder field​(java.lang.String name,
                                      int fragmentSize,
                                      int numberOfFragments)
        Adds a field to be highlighted with a provided fragment size (in characters), and a provided (maximum) number of fragments.
        Parameters:
        name - The field to highlight
        fragmentSize - The size of a fragment in characters
        numberOfFragments - The (maximum) number of fragments
      • field

        public HighlightBuilder field​(java.lang.String name,
                                      int fragmentSize,
                                      int numberOfFragments,
                                      int fragmentOffset)
        Adds a field to be highlighted with a provided fragment size (in characters), and a provided (maximum) number of fragments.
        Parameters:
        name - The field to highlight
        fragmentSize - The size of a fragment in characters
        numberOfFragments - The (maximum) number of fragments
        fragmentOffset - The offset from the start of the fragment to the start of the highlight
      • tagsSchema

        public HighlightBuilder tagsSchema​(java.lang.String schemaName)
        Set a tag scheme that encapsulates a built in pre and post tags. The allowed schemes are styled and default.
        Parameters:
        schemaName - The tag scheme name
      • encoder

        public HighlightBuilder encoder​(java.lang.String encoder)
        Set encoder for the highlighting are html and default.
        Parameters:
        encoder - name
      • useExplicitFieldOrder

        public HighlightBuilder useExplicitFieldOrder​(boolean useExplicitFieldOrder)
        Send the fields to be highlighted using a syntax that is specific about the order in which they should be highlighted.
        Returns:
        this for chaining
      • rewrite

        public HighlightBuilder rewrite​(QueryRewriteContext ctx)
                                 throws java.io.IOException
        Description copied from interface: Rewriteable
        Rewrites this instance based on the provided context. The returned objects will be the same instance as this if no changes during the rewrite were applied.
        Throws:
        java.io.IOException