Class AbstractHighlighterBuilder<HB extends AbstractHighlighterBuilder<?>>

java.lang.Object
org.elasticsearch.search.fetch.subphase.highlight.AbstractHighlighterBuilder<HB>
All Implemented Interfaces:
Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, Rewriteable<HB>
Direct Known Subclasses:
HighlightBuilder, HighlightBuilder.Field

public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterBuilder<?>> extends Object implements Writeable, Rewriteable<HB>, org.elasticsearch.common.xcontent.ToXContentObject
This abstract class holds parameters shared by HighlightBuilder and HighlightBuilder.Field and provides the common setters, equality, hashCode calculation and common serialization
  • Field Details

    • PRE_TAGS_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField PRE_TAGS_FIELD
    • POST_TAGS_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField POST_TAGS_FIELD
    • FIELDS_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField FIELDS_FIELD
    • ORDER_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField ORDER_FIELD
    • HIGHLIGHT_FILTER_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField HIGHLIGHT_FILTER_FIELD
    • FRAGMENT_SIZE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField FRAGMENT_SIZE_FIELD
    • FRAGMENT_OFFSET_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField FRAGMENT_OFFSET_FIELD
    • NUMBER_OF_FRAGMENTS_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField NUMBER_OF_FRAGMENTS_FIELD
    • ENCODER_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField ENCODER_FIELD
    • REQUIRE_FIELD_MATCH_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField REQUIRE_FIELD_MATCH_FIELD
    • BOUNDARY_SCANNER_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_SCANNER_FIELD
    • BOUNDARY_MAX_SCAN_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_MAX_SCAN_FIELD
    • BOUNDARY_CHARS_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_CHARS_FIELD
    • BOUNDARY_SCANNER_LOCALE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField BOUNDARY_SCANNER_LOCALE_FIELD
    • TYPE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField TYPE_FIELD
    • FRAGMENTER_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField FRAGMENTER_FIELD
    • NO_MATCH_SIZE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField NO_MATCH_SIZE_FIELD
    • FORCE_SOURCE_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField FORCE_SOURCE_FIELD
    • PHRASE_LIMIT_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField PHRASE_LIMIT_FIELD
    • OPTIONS_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField OPTIONS_FIELD
    • HIGHLIGHT_QUERY_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField HIGHLIGHT_QUERY_FIELD
    • MATCHED_FIELDS_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField MATCHED_FIELDS_FIELD
    • MAX_ANALYZED_OFFSET_FIELD

      public static final org.elasticsearch.common.xcontent.ParseField MAX_ANALYZED_OFFSET_FIELD
    • preTags

      protected String[] preTags
    • postTags

      protected String[] postTags
    • fragmentSize

      protected Integer fragmentSize
    • numOfFragments

      protected Integer numOfFragments
    • highlighterType

      protected String highlighterType
    • fragmenter

      protected String fragmenter
    • highlightQuery

      protected QueryBuilder highlightQuery
    • order

      protected HighlightBuilder.Order order
    • highlightFilter

      protected Boolean highlightFilter
    • forceSource

      protected Boolean forceSource
    • boundaryScannerType

      protected HighlightBuilder.BoundaryScannerType boundaryScannerType
    • boundaryMaxScan

      protected Integer boundaryMaxScan
    • boundaryChars

      protected char[] boundaryChars
    • boundaryScannerLocale

      protected Locale boundaryScannerLocale
    • noMatchSize

      protected Integer noMatchSize
    • phraseLimit

      protected Integer phraseLimit
    • options

      protected Map<String,Object> options
    • requireFieldMatch

      protected Boolean requireFieldMatch
    • maxAnalyzedOffset

      protected Integer maxAnalyzedOffset
  • Constructor Details

  • Method Details

    • writeTo

      public final void writeTo(StreamOutput out) throws IOException
      write common parameters to StreamOutput
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • doWriteTo

      protected abstract void doWriteTo(StreamOutput out) throws IOException
      Throws:
      IOException
    • preTags

      public HB preTags(String... preTags)
      Set the pre tags that will be used for highlighting.
    • preTags

      public String[] preTags()
      Returns:
      the value set by preTags(String...)
    • postTags

      public HB postTags(String... postTags)
      Set the post tags that will be used for highlighting.
    • postTags

      public String[] postTags()
      Returns:
      the value set by postTags(String...)
    • fragmentSize

      public HB fragmentSize(Integer fragmentSize)
      Set the fragment size in characters, defaults to HighlightBuilder.DEFAULT_FRAGMENT_CHAR_SIZE
    • fragmentSize

      public Integer fragmentSize()
      Returns:
      the value set by fragmentSize(Integer)
    • numOfFragments

      public HB numOfFragments(Integer numOfFragments)
      Set the number of fragments, defaults to HighlightBuilder.DEFAULT_NUMBER_OF_FRAGMENTS
    • numOfFragments

      public Integer numOfFragments()
      Returns:
      the value set by numOfFragments(Integer)
    • highlighterType

      public HB highlighterType(String highlighterType)
      Set type of highlighter to use. Out of the box supported types are unified, plain and fvh. Defaults to unified. Details of the different highlighter types are covered in the reference guide.
    • highlighterType

      public String highlighterType()
      Returns:
      the value set by highlighterType(String)
    • fragmenter

      public HB fragmenter(String fragmenter)
      Sets what fragmenter to use to break up text that is eligible for highlighting. This option is only applicable when using the plain highlighterType highlighter. Permitted values are "simple" or "span" relating to SimpleFragmenter and SimpleSpanFragmenter implementations respectively with the default being "span"
    • fragmenter

      public String fragmenter()
      Returns:
      the value set by fragmenter(String)
    • highlightQuery

      public HB highlightQuery(QueryBuilder highlightQuery)
      Sets a query to be used for highlighting instead of the search query.
    • highlightQuery

      public QueryBuilder highlightQuery()
      Returns:
      the value set by highlightQuery(QueryBuilder)
    • order

      public HB order(String order)
      The order of fragments per field. By default, ordered by the order in the highlighted text. Can be score, which then it will be ordered by score of the fragments, or none.
    • order

      public HB order(HighlightBuilder.Order scoreOrdered)
      By default, fragments of a field are ordered by the order in the highlighted text. If set to HighlightBuilder.Order.SCORE, this changes order to score of the fragments.
    • order

      public HighlightBuilder.Order order()
      Returns:
      the value set by order(Order)
    • highlightFilter

      public HB highlightFilter(Boolean highlightFilter)
      Set this to true when using the highlighterType fvh and you want to provide highlighting on filter clauses in your query. Default is false.
    • highlightFilter

      public Boolean highlightFilter()
      Returns:
      the value set by highlightFilter(Boolean)
    • boundaryScannerType

      public HB boundaryScannerType(String boundaryScannerType)
      When using the highlighterType fvh this setting controls which scanner to use for fragment boundaries, and defaults to "simple".
    • boundaryScannerType

      public HB boundaryScannerType(HighlightBuilder.BoundaryScannerType boundaryScannerType)
      When using the highlighterType fvh this setting controls which scanner to use for fragment boundaries, and defaults to "simple".
    • boundaryScannerType

      public HighlightBuilder.BoundaryScannerType boundaryScannerType()
      Returns:
      the value set by boundaryScannerType(String)
    • boundaryMaxScan

      public HB boundaryMaxScan(Integer boundaryMaxScan)
      When using the highlighterType fvh this setting controls how far to look for boundary characters, and defaults to 20.
    • boundaryMaxScan

      public Integer boundaryMaxScan()
      Returns:
      the value set by boundaryMaxScan(Integer)
    • boundaryChars

      public HB boundaryChars(char[] boundaryChars)
      When using the highlighterType fvh this setting defines what constitutes a boundary for highlighting. It’s a single string with each boundary character defined in it. It defaults to .,!? \t\n
    • boundaryChars

      public char[] boundaryChars()
      Returns:
      the value set by boundaryChars(char[])
    • boundaryScannerLocale

      public HB boundaryScannerLocale(String boundaryScannerLocale)
      When using the highlighterType fvh and boundaryScannerType break_iterator, this setting controls the locale to use by the BreakIterator, defaults to "root".
    • boundaryScannerLocale

      public Locale boundaryScannerLocale()
      Returns:
      the value set by boundaryScannerLocale(String)
    • options

      public HB options(Map<String,Object> options)
      Allows to set custom options for custom highlighters.
    • options

      public Map<String,Object> options()
      Returns:
      the value set by options(Map)
    • requireFieldMatch

      public HB requireFieldMatch(Boolean requireFieldMatch)
      Set to true to cause a field to be highlighted only if a query matches that field. Default is false meaning that terms are highlighted on all requested fields regardless if the query matches specifically on them.
    • requireFieldMatch

      public Boolean requireFieldMatch()
      Returns:
      the value set by requireFieldMatch(Boolean)
    • noMatchSize

      public HB noMatchSize(Integer noMatchSize)
      Sets the size of the fragment to return from the beginning of the field if there are no matches to highlight and the field doesn't also define noMatchSize.
      Parameters:
      noMatchSize - integer to set or null to leave out of request. default is null.
      Returns:
      this for chaining
    • noMatchSize

      public Integer noMatchSize()
      Returns:
      the value set by noMatchSize(Integer)
    • phraseLimit

      public HB phraseLimit(Integer phraseLimit)
      Sets the maximum number of phrases the fvh will consider if the field doesn't also define phraseLimit.
      Parameters:
      phraseLimit - maximum number of phrases the fvh will consider
      Returns:
      this for chaining
    • phraseLimit

      public Integer phraseLimit()
      Returns:
      the value set by phraseLimit(Integer)
    • forceSource

      public HB forceSource(Boolean forceSource)
      Forces the highlighting to highlight fields based on the source even if fields are stored separately.
    • forceSource

      public Boolean forceSource()
      Returns:
      the value set by forceSource(Boolean)
    • maxAnalyzedOffset

      public HB maxAnalyzedOffset(Integer maxAnalyzedOffset)
      Set to a non-negative value which represents the max offset used to analyze the field thus avoiding exceptions if the field exceeds this limit.
    • maxAnalyzedOffset

      public Integer maxAnalyzedOffset()
      Returns:
      the value set by maxAnalyzedOffset(Integer)
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      IOException
    • innerXContent

      protected abstract void innerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder) throws IOException
      Throws:
      IOException
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • doHashCode

      protected abstract int doHashCode()
      fields only present in subclass should contribute to hashCode in the implementation
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • doEquals

      protected abstract boolean doEquals(HB other)
      fields only present in subclass should be checked for equality in the implementation
    • toString

      public String toString()
      Overrides:
      toString in class Object