Class PerFieldKnnVectorsFormat
- java.lang.Object
-
- org.apache.lucene.codecs.KnnVectorsFormat
-
- org.apache.lucene.codecs.perfield.PerFieldKnnVectorsFormat
-
- All Implemented Interfaces:
NamedSPILoader.NamedSPI
public abstract class PerFieldKnnVectorsFormat extends KnnVectorsFormat
Enables per field numeric vector support.Note, when extending this class, the name (
KnnVectorsFormat.getName()) is written into the index. In order for the field to be read, the name must resolve to your implementation viaKnnVectorsFormat.forName(String). This method uses Java'sService Provider Interfaceto resolve format names.Files written by each numeric vectors format have an additional suffix containing the format name. For example, in a per-field configuration instead of
_1.datfilenames would look like_1_Lucene40_0.dat.- See Also:
ServiceLoader- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPerFieldKnnVectorsFormat.FieldsReaderVectorReader that can wrap multiple delegate readers, selected by field.
-
Field Summary
Fields Modifier and Type Field Description static StringPER_FIELD_FORMAT_KEYFieldInfoattribute name used to store the format name for each field.static StringPER_FIELD_NAMEName of thisKnnVectorsFormat.static StringPER_FIELD_SUFFIX_KEYFieldInfoattribute name used to store the segment suffix name for each field.-
Fields inherited from class org.apache.lucene.codecs.KnnVectorsFormat
DEFAULT_MAX_DIMENSIONS, EMPTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPerFieldKnnVectorsFormat()Sole constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description KnnVectorsReaderfieldsReader(SegmentReadState state)Returns aKnnVectorsReaderto read the vectors from the index.KnnVectorsWriterfieldsWriter(SegmentWriteState state)Returns aKnnVectorsWriterto write the vectors to the index.abstract KnnVectorsFormatgetKnnVectorsFormatForField(String field)Returns the numeric vector format that should be used for writing new segments offield.intgetMaxDimensions(String fieldName)Returns the maximum number of vector dimensions supported by this codec for the given field name-
Methods inherited from class org.apache.lucene.codecs.KnnVectorsFormat
availableKnnVectorsFormats, forName, getName, reloadKnnVectorsFormat
-
-
-
-
Field Detail
-
PER_FIELD_NAME
public static final String PER_FIELD_NAME
Name of thisKnnVectorsFormat.- See Also:
- Constant Field Values
-
PER_FIELD_FORMAT_KEY
public static final String PER_FIELD_FORMAT_KEY
FieldInfoattribute name used to store the format name for each field.
-
-
Method Detail
-
fieldsWriter
public KnnVectorsWriter fieldsWriter(SegmentWriteState state) throws IOException
Description copied from class:KnnVectorsFormatReturns aKnnVectorsWriterto write the vectors to the index.- Specified by:
fieldsWriterin classKnnVectorsFormat- Throws:
IOException
-
fieldsReader
public KnnVectorsReader fieldsReader(SegmentReadState state) throws IOException
Description copied from class:KnnVectorsFormatReturns aKnnVectorsReaderto read the vectors from the index.- Specified by:
fieldsReaderin classKnnVectorsFormat- Throws:
IOException
-
getMaxDimensions
public int getMaxDimensions(String fieldName)
Description copied from class:KnnVectorsFormatReturns the maximum number of vector dimensions supported by this codec for the given field nameCodecs should override this method to specify the maximum number of dimensions they support.
- Overrides:
getMaxDimensionsin classKnnVectorsFormat- Parameters:
fieldName- the field name- Returns:
- the maximum number of vector dimensions.
-
getKnnVectorsFormatForField
public abstract KnnVectorsFormat getKnnVectorsFormatForField(String field)
Returns the numeric vector format that should be used for writing new segments offield.The field to format mapping is written to the index, so this method is only invoked when writing, not when reading.
-
-