Interface LuceneFieldCodec<F,E>

Type Parameters:
F - The field type as declared on
E - The encoded type. For example, for a LocalDate field this will be Long.
All Known Subinterfaces:
LuceneVectorFieldCodec<F>
All Known Implementing Classes:
AbstractLuceneNumericFieldCodec, AbstractLuceneVectorFieldCodec, LuceneBigDecimalFieldCodec, LuceneBigIntegerFieldCodec, LuceneBooleanFieldCodec, LuceneByteFieldCodec, LuceneByteVectorCodec, LuceneDoubleFieldCodec, LuceneFieldFieldCodec, LuceneFloatFieldCodec, LuceneFloatVectorCodec, LuceneGeoPointFieldCodec, LuceneInstantFieldCodec, LuceneIntegerFieldCodec, LuceneLocalDateFieldCodec, LuceneLocalDateTimeFieldCodec, LuceneLocalTimeFieldCodec, LuceneLongFieldCodec, LuceneMonthDayFieldCodec, LuceneOffsetDateTimeFieldCodec, LuceneOffsetTimeFieldCodec, LuceneShortFieldCodec, LuceneStringFieldCodec, LuceneYearFieldCodec, LuceneYearMonthFieldCodec, LuceneZonedDateTimeFieldCodec

public interface LuceneFieldCodec<F,E>
Defines how a given value will be encoded in the Lucene document and how it will be decoded.

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

  • Method Details

    • addToDocument

      void addToDocument(LuceneDocumentContent documentBuilder, String absoluteFieldPath, F value)
      Encode the given value in the document by adding new fields to the Lucene document.
      Parameters:
      documentBuilder - The document builder.
      absoluteFieldPath - The absolute path of the field.
      value - The value to encode.
    • decode

      F decode(org.apache.lucene.index.IndexableField field)
      Extract the value from the given stored field.

      Typically used in projections.

      Parameters:
      field - The document field. Never null.
      Returns:
      The decoded value.
    • raw

      E raw(org.apache.lucene.index.IndexableField field)
    • decode

      F decode(E field)
    • encode

      E encode(F value)
      Encode the given value.

      Useful for predicates and sorts in particular.

      Parameters:
      value - The value to encode.
    • encodedType

      Class<E> encodedType()
      Returns:
      The type of the encoded value.
    • isCompatibleWith

      boolean isCompatibleWith(LuceneFieldCodec<?,?> other)
      Determine whether the given codec provides an encoding that is compatible with this codec, i.e. whether its decode(IndexableField) and encode(Object) methods behave the same way.

      NOTE: addToDocument(LuceneDocumentContent, String, Object) may behave differently, e.g. it may add docvalues while this codec does not. The behavior of addToDocument(LuceneDocumentContent, String, Object) is considered irrelevant when checking the equivalence of encoding, because such differences should be accounted for through other ways (fields being assigned incompatible predicate factories, etc.).

      Parameters:
      other - Another LuceneFieldCodec, never null.
      Returns:
      true if the given codec is compatible. false otherwise, or when in doubt.