Interface ElasticsearchFieldCodec<F>

All Known Subinterfaces:
ElasticsearchVectorFieldCodec<F>
All Known Implementing Classes:
AbstractElasticsearchFieldCodec, AbstractElasticsearchJavaTimeFieldCodec, AbstractElasticsearchVectorFieldCodec, ElasticsearchBigDecimalFieldCodec, ElasticsearchBigIntegerFieldCodec, ElasticsearchBooleanFieldCodec, ElasticsearchByteFieldCodec, ElasticsearchByteVectorFieldCodec, ElasticsearchDoubleFieldCodec, ElasticsearchFloatFieldCodec, ElasticsearchFloatVectorFieldCodec, ElasticsearchGeoPointFieldCodec, ElasticsearchInstantFieldCodec, ElasticsearchIntegerFieldCodec, ElasticsearchJsonElementFieldCodec, ElasticsearchLocalDateFieldCodec, ElasticsearchLocalDateTimeFieldCodec, ElasticsearchLocalTimeFieldCodec, ElasticsearchLongFieldCodec, ElasticsearchMonthDayFieldCodec, ElasticsearchOffsetDateTimeFieldCodec, ElasticsearchOffsetTimeFieldCodec, ElasticsearchShortFieldCodec, ElasticsearchStringFieldCodec, ElasticsearchYearFieldCodec, ElasticsearchYearMonthFieldCodec, ElasticsearchZonedDateTimeFieldCodec

public interface ElasticsearchFieldCodec<F>
Defines how a given value will be encoded as JSON and decoded from JSON.

Encodes values received from an IndexFieldReference when indexing, and returns decoded values to the ElasticsearchSearchProjection when projecting in a search query.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Whether this codec can extract data from JsonArrays when decoding.
    decode(com.google.gson.JsonElement element)
     
    default F
    decodeAggregationKey(com.google.gson.JsonElement key, com.google.gson.JsonElement keyAsString)
    Decodes the key returned by a term aggregation.
    com.google.gson.JsonElement
    encode(F value)
     
    default com.google.gson.JsonElement
    Encodes a value for inclusion in an aggregation request.
    default com.google.gson.JsonElement
     
    fromJsonElementToString(com.google.gson.JsonElement value)
     
    com.google.gson.JsonElement
     
    boolean
    Determine whether another codec is compatible with this one, i.e. whether it will encode/decode the information to/from the document in a compatible way.
  • Method Details

    • encode

      com.google.gson.JsonElement encode(F value)
    • encodeForMissing

      default com.google.gson.JsonElement encodeForMissing(F value)
    • encodeForAggregation

      default com.google.gson.JsonElement encodeForAggregation(ElasticsearchSearchSyntax searchSyntax, F value)
      Encodes a value for inclusion in an aggregation request.
      Parameters:
      searchSyntax - The search syntax.
      value - The value to encode.
      Returns:
      The encoded value.
    • decode

      F decode(com.google.gson.JsonElement element)
    • decodeAggregationKey

      default F decodeAggregationKey(com.google.gson.JsonElement key, com.google.gson.JsonElement keyAsString)
      Decodes the key returned by a term aggregation.
      Parameters:
      key - The "key" property returned by the aggregation. May be a number, a string, ... depending on the field type.
      keyAsString - The "key_as_string" property returned by the term aggregation. Either null or a JsonPrimitive containing a string.
      Returns:
      The decoded term.
    • isCompatibleWith

      boolean isCompatibleWith(ElasticsearchFieldCodec<?> other)
      Determine whether another codec is compatible with this one, i.e. whether it will encode/decode the information to/from the document in a compatible way.
      Parameters:
      other - Another ElasticsearchFieldCodec, never null.
      Returns:
      true if the given codec is compatible. false otherwise, or when in doubt.
    • canDecodeArrays

      default boolean canDecodeArrays()
      Whether this codec can extract data from JsonArrays when decoding.
    • fromJsonStringToElement

      com.google.gson.JsonElement fromJsonStringToElement(String value)
    • fromJsonElementToString

      String fromJsonElementToString(com.google.gson.JsonElement value)