Record Class HighlightOptions

java.lang.Object
java.lang.Record
org.elasticsearch.xpack.esql.plan.logical.HighlightOptions

public record HighlightOptions(String preTag, String postTag, String encoder, int numberOfFragments, int fragmentSize, int noMatchSize, String boundaryScanner, Locale boundaryScannerLocale, String order, int maxAnalyzedOffset) extends Record
Resolved, plain-Java view of the WITH { ... } options of a Highlight command, with defaults applied. Built once at local-execution-planning time from the (foldable) MapExpression so the operator factory only deals with primitives.

boundary_chars, boundary_max_scan and phrase_limit are accepted for Query DSL parity but are only honoured by the FastVectorHighlighter. HIGHLIGHT always uses the unified highlighter, so they are grammar-only no-ops that never reach this record.

The validation done while building this record is also the single source of truth for analysis-time checks: Highlight.postAnalysisVerification(org.elasticsearch.xpack.esql.common.Failures) reuses validate(java.lang.String, org.elasticsearch.xpack.esql.core.expression.Expression, org.elasticsearch.xpack.esql.core.expression.FoldContext) so invalid values fail during analysis rather than only later during local planning.

  • Field Details

  • Constructor Details

    • HighlightOptions

      public HighlightOptions(String preTag, String postTag, String encoder, int numberOfFragments, int fragmentSize, int noMatchSize, String boundaryScanner, Locale boundaryScannerLocale, String order, int maxAnalyzedOffset)
      Creates an instance of a HighlightOptions record class.
      Parameters:
      preTag - the value for the preTag record component
      postTag - the value for the postTag record component
      encoder - the value for the encoder record component
      numberOfFragments - the value for the numberOfFragments record component
      fragmentSize - the value for the fragmentSize record component
      noMatchSize - the value for the noMatchSize record component
      boundaryScanner - the value for the boundaryScanner record component
      boundaryScannerLocale - the value for the boundaryScannerLocale record component
      order - the value for the order record component
      maxAnalyzedOffset - the value for the maxAnalyzedOffset record component
  • Method Details

    • from

      public static HighlightOptions from(MapExpression options, FoldContext foldContext)
    • validate

      public static void validate(String name, Expression value, FoldContext foldContext)
      Type/range-checks a single (non-null, foldable) option value by parsing it exactly as from(org.elasticsearch.xpack.esql.core.expression.MapExpression, org.elasticsearch.xpack.esql.core.expression.FoldContext) would and discarding the result, throwing IllegalArgumentException on a bad value. Enum options (encoder, boundary_scanner, order) are checked separately against their HighlightOptions.EnumOption descriptor, and phrase_limit is grammar-only, so all of them are no-ops here. boundary_chars and boundary_max_scan are FastVectorHighlighter-only at execution but we still type-check them for Query DSL parity.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • preTag

      public String preTag()
      Returns the value of the preTag record component.
      Returns:
      the value of the preTag record component
    • postTag

      public String postTag()
      Returns the value of the postTag record component.
      Returns:
      the value of the postTag record component
    • encoder

      public String encoder()
      Returns the value of the encoder record component.
      Returns:
      the value of the encoder record component
    • numberOfFragments

      public int numberOfFragments()
      Returns the value of the numberOfFragments record component.
      Returns:
      the value of the numberOfFragments record component
    • fragmentSize

      public int fragmentSize()
      Returns the value of the fragmentSize record component.
      Returns:
      the value of the fragmentSize record component
    • noMatchSize

      public int noMatchSize()
      Returns the value of the noMatchSize record component.
      Returns:
      the value of the noMatchSize record component
    • boundaryScanner

      public String boundaryScanner()
      Returns the value of the boundaryScanner record component.
      Returns:
      the value of the boundaryScanner record component
    • boundaryScannerLocale

      public Locale boundaryScannerLocale()
      Returns the value of the boundaryScannerLocale record component.
      Returns:
      the value of the boundaryScannerLocale record component
    • order

      public String order()
      Returns the value of the order record component.
      Returns:
      the value of the order record component
    • maxAnalyzedOffset

      public int maxAnalyzedOffset()
      Returns the value of the maxAnalyzedOffset record component.
      Returns:
      the value of the maxAnalyzedOffset record component