Class PerFieldKnnVectorsFormat
java.lang.Object
org.apache.lucene.codecs.KnnVectorsFormat
org.apache.lucene.codecs.perfield.PerFieldKnnVectorsFormat
- All Implemented Interfaces:
NamedSPILoader.NamedSPI
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 via KnnVectorsFormat.forName(String)
. This method uses Java's Service Provider Interface
to
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.dat
filenames would
look like _1_Lucene40_0.dat
.
- See Also:
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
VectorReader that can wrap multiple delegate readers, selected by field. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
FieldInfo
attribute name used to store the format name for each field.static final String
Name of thisKnnVectorsFormat
.static final String
FieldInfo
attribute name used to store the segment suffix name for each field.Fields inherited from class org.apache.lucene.codecs.KnnVectorsFormat
EMPTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfieldsReader
(SegmentReadState state) Returns aKnnVectorsReader
to read the vectors from the index.fieldsWriter
(SegmentWriteState state) Returns aKnnVectorsWriter
to write the vectors to the index.abstract KnnVectorsFormat
Returns the numeric vector format that should be used for writing new segments offield
.Methods inherited from class org.apache.lucene.codecs.KnnVectorsFormat
forName, getName
-
Field Details
-
PER_FIELD_NAME
Name of thisKnnVectorsFormat
.- See Also:
-
PER_FIELD_FORMAT_KEY
FieldInfo
attribute name used to store the format name for each field. -
PER_FIELD_SUFFIX_KEY
FieldInfo
attribute name used to store the segment suffix name for each field.
-
-
Constructor Details
-
PerFieldKnnVectorsFormat
protected PerFieldKnnVectorsFormat()Sole constructor.
-
-
Method Details
-
fieldsWriter
Description copied from class:KnnVectorsFormat
Returns aKnnVectorsWriter
to write the vectors to the index.- Specified by:
fieldsWriter
in classKnnVectorsFormat
- Throws:
IOException
-
fieldsReader
Description copied from class:KnnVectorsFormat
Returns aKnnVectorsReader
to read the vectors from the index.- Specified by:
fieldsReader
in classKnnVectorsFormat
- Throws:
IOException
-
getKnnVectorsFormatForField
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.
-