Class AbstractLuceneVectorFieldCodec<F>

java.lang.Object
org.hibernate.search.backend.lucene.types.codec.impl.AbstractLuceneVectorFieldCodec<F>
All Implemented Interfaces:
LuceneFieldCodec<F,F>, LuceneVectorFieldCodec<F>
Direct Known Subclasses:
LuceneByteVectorCodec, LuceneFloatVectorCodec

public abstract class AbstractLuceneVectorFieldCodec<F> extends Object implements LuceneVectorFieldCodec<F>
  • Field Details

    • log

      protected static final Log log
    • fieldType

      protected final org.apache.lucene.document.FieldType fieldType
    • vectorSimilarity

      protected final org.apache.lucene.index.VectorSimilarityFunction vectorSimilarity
  • Constructor Details

    • AbstractLuceneVectorFieldCodec

      protected AbstractLuceneVectorFieldCodec(org.apache.lucene.index.VectorSimilarityFunction vectorSimilarity, int dimension, Storage storage, Indexing indexing, F indexNullAsValue, HibernateSearchKnnVectorsFormat knnVectorsFormat, Consumer<F> checkVectorConsumer)
  • Method Details

    • addToDocument

      public final void addToDocument(LuceneDocumentContent documentBuilder, String absoluteFieldPath, F value)
      Description copied from interface: LuceneFieldCodec
      Encode the given value in the document by adding new fields to the Lucene document.
      Specified by:
      addToDocument in interface LuceneFieldCodec<F,F>
      Parameters:
      documentBuilder - The document builder.
      absoluteFieldPath - The absolute path of the field.
      value - The value to encode.
    • encode

      public final F encode(F value)
      Description copied from interface: LuceneFieldCodec
      Encode the given value.

      Useful for predicates and sorts in particular.

      Specified by:
      encode in interface LuceneFieldCodec<F,F>
      Parameters:
      value - The value to encode.
    • decode

      public F decode(F field)
      Specified by:
      decode in interface LuceneFieldCodec<F,F>
    • toByteArray

      protected abstract byte[] toByteArray(F value)
    • isCompatibleWith

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

      NOTE: LuceneFieldCodec.addToDocument(LuceneDocumentContent, String, Object) may behave differently, e.g. it may add docvalues while this codec does not. The behavior of LuceneFieldCodec.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.).

      Specified by:
      isCompatibleWith in interface LuceneFieldCodec<F,F>
      Parameters:
      obj - Another LuceneFieldCodec, never null.
      Returns:
      true if the given codec is compatible. false otherwise, or when in doubt.
    • createIndexField

      protected abstract org.apache.lucene.index.IndexableField createIndexField(String absoluteFieldPath, F value)
    • vectorEncoding

      protected abstract org.apache.lucene.index.VectorEncoding vectorEncoding()
    • knnVectorFormat

      public org.apache.lucene.codecs.KnnVectorsFormat knnVectorFormat()
      Description copied from interface: LuceneVectorFieldCodec
      Custom knn vector format that will be used in PerFieldKnnVectorsFormat and can for example define custom efConstruction or m or even provide a completely custom implementation (needs to be registered via ServiceLoader mechanism).
      Specified by:
      knnVectorFormat in interface LuceneVectorFieldCodec<F>
    • getConfiguredDimensions

      public int getConfiguredDimensions()
      Specified by:
      getConfiguredDimensions in interface LuceneVectorFieldCodec<F>
      Returns:
      The number of dimensions (array length) of vectors to be indexed that this codec can process.
    • getVectorSimilarity

      public org.apache.lucene.index.VectorSimilarityFunction getVectorSimilarity()
      Specified by:
      getVectorSimilarity in interface LuceneVectorFieldCodec<F>
      Returns:
      The vector similarity function used by this codec.
    • toString

      public String toString()
      Overrides:
      toString in class Object