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 Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.lucene.document.FieldTypeprotected static final Logprotected final org.apache.lucene.index.VectorSimilarityFunction -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractLuceneVectorFieldCodec(org.apache.lucene.index.VectorSimilarityFunction vectorSimilarity, int dimension, Storage storage, Indexing indexing, F indexNullAsValue, HibernateSearchKnnVectorsFormat knnVectorsFormat, Consumer<F> checkVectorConsumer) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddToDocument(LuceneDocumentContent documentBuilder, String absoluteFieldPath, F value) Encode the given value in the document by adding new fields to the Lucene document.protected abstract org.apache.lucene.index.IndexableFieldcreateIndexField(String absoluteFieldPath, F value) final FEncode the given value.intorg.apache.lucene.index.VectorSimilarityFunctionbooleanisCompatibleWith(LuceneFieldCodec<?, ?> obj) Determine whether the given codec provides an encoding that is compatible with this codec, i.e. whether itsLuceneFieldCodec.decode(IndexableField)andLuceneFieldCodec.encode(Object)methods behave the same way.org.apache.lucene.codecs.KnnVectorsFormatCustomknn vector formatthat will be used inPerFieldKnnVectorsFormatand can for example define customefConstructionormor even provide a completely custom implementation (needs to be registered via ServiceLoader mechanism).protected abstract byte[]toByteArray(F value) toString()protected abstract org.apache.lucene.index.VectorEncodingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hibernate.search.backend.lucene.types.codec.impl.LuceneFieldCodec
decode, encodedType, rawMethods inherited from interface org.hibernate.search.backend.lucene.types.codec.impl.LuceneVectorFieldCodec
similarityDistanceToScore, vectorElementsType
-
Field Details
-
log
-
fieldType
protected final org.apache.lucene.document.FieldType fieldType -
vectorSimilarity
protected final org.apache.lucene.index.VectorSimilarityFunction vectorSimilarity
-
-
Constructor Details
-
AbstractLuceneVectorFieldCodec
-
-
Method Details
-
addToDocument
public final void addToDocument(LuceneDocumentContent documentBuilder, String absoluteFieldPath, F value) Description copied from interface:LuceneFieldCodecEncode the given value in the document by adding new fields to the Lucene document.- Specified by:
addToDocumentin interfaceLuceneFieldCodec<F,F> - Parameters:
documentBuilder- The document builder.absoluteFieldPath- The absolute path of the field.value- The value to encode.
-
encode
Description copied from interface:LuceneFieldCodecEncode the given value.Useful for predicates and sorts in particular.
- Specified by:
encodein interfaceLuceneFieldCodec<F,F> - Parameters:
value- The value to encode.
-
decode
- Specified by:
decodein interfaceLuceneFieldCodec<F,F>
-
toByteArray
-
isCompatibleWith
Description copied from interface:LuceneFieldCodecDetermine whether the given codec provides an encoding that is compatible with this codec, i.e. whether itsLuceneFieldCodec.decode(IndexableField)andLuceneFieldCodec.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 ofLuceneFieldCodec.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:
isCompatibleWithin interfaceLuceneFieldCodec<F,F> - Parameters:
obj- AnotherLuceneFieldCodec, nevernull.- Returns:
trueif the given codec is compatible.falseotherwise, or when in doubt.
-
createIndexField
-
vectorEncoding
protected abstract org.apache.lucene.index.VectorEncoding vectorEncoding() -
knnVectorFormat
public org.apache.lucene.codecs.KnnVectorsFormat knnVectorFormat()Description copied from interface:LuceneVectorFieldCodecCustomknn vector formatthat will be used inPerFieldKnnVectorsFormatand can for example define customefConstructionormor even provide a completely custom implementation (needs to be registered via ServiceLoader mechanism).- Specified by:
knnVectorFormatin interfaceLuceneVectorFieldCodec<F>
-
getConfiguredDimensions
public int getConfiguredDimensions()- Specified by:
getConfiguredDimensionsin interfaceLuceneVectorFieldCodec<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:
getVectorSimilarityin interfaceLuceneVectorFieldCodec<F>- Returns:
- The vector similarity function used by this codec.
-
toString
-