Class DenseVectorField
- All Implemented Interfaces:
FloatValueFieldType,NumericValueFieldType
- Direct Known Subclasses:
BinaryQuantizedDenseVectorField,ScalarQuantizedDenseVectorField
KnnByteVectorField
and KnnFloatVectorField. See KnnByteVectorQuery and KnnFloatVectorQuery for more details. It supports a fixed cardinality
dimension for the vector and a fixed similarity function. The default similarity is
EUCLIDEAN_HNSW (L2). The default algorithm is HNSW. For Lucene 9.1 e.g. See HnswGraph for more details about the implementation. Only
Indexed and Stored attributes are supported.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.solr.schema.FieldType
FieldType.DefaultAnalyzer, FieldType.MultiValueSelector -
Field Summary
FieldsFields inherited from class org.apache.solr.schema.PointField
TEST_HACK_IGNORE_USELESS_TRIEFIELD_ARGSFields inherited from class org.apache.solr.schema.NumericFieldType
doubleOrFloat, typeFields inherited from class org.apache.solr.schema.FieldType
ANALYZER, args, AUTO_GENERATE_PHRASE_QUERIES, CHAR_FILTER, CHAR_FILTERS, CLASS_NAME, docValuesFormat, ENABLE_GRAPH_QUERIES, falseProperties, FILTER, FILTERS, INDEX, INDEX_ANALYZER, MULTI_TERM, MULTI_TERM_ANALYZER, POLY_FIELD_SEPARATOR, postingsFormat, properties, QUERY, QUERY_ANALYZER, similarity, SIMILARITY, similarityFactory, SYNONYM_QUERY_STYLE, TOKENIZER, trueProperties, TYPE, TYPE_NAME, typeNameFields inherited from class org.apache.solr.schema.FieldProperties
BINARY, DOC_VALUES, INDEXED, LARGE_FIELD, MULTIVALUED, OMIT_NORMS, OMIT_POSITIONS, OMIT_TF_POSITIONS, REQUIRED, SORT_MISSING_FIRST, SORT_MISSING_LAST, STORE_OFFSETS, STORE_TERMOFFSETS, STORE_TERMPAYLOADS, STORE_TERMPOSITIONS, STORE_TERMVECTORS, STORED, TOKENIZED, UNINVERTIBLE, USE_DOCVALUES_AS_STORED -
Constructor Summary
ConstructorsConstructorDescriptionDenseVectorField(int dimension) DenseVectorField(int dimension, org.apache.lucene.index.VectorEncoding vectorEncoding) DenseVectorField(int dimension, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, org.apache.lucene.index.VectorEncoding vectorEncoding) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.lucene.codecs.KnnVectorsFormatvoidcheckSchemaField(SchemaField field) Check'sSchemaFieldinstances constructed using this field type to ensure that they are valid.org.apache.lucene.index.IndexableFieldcreateField(SchemaField field, Object vectorValue) Used for adding a document when a field needs to be created from a type and a string.List<org.apache.lucene.index.IndexableField> createFields(SchemaField field, Object value) Given aSchemaField, create one or moreIndexableFieldinstancesprotected booleanReturns whether this field type should enable docValues by default for schemaVersion >= 1.7.intintintintintintintorg.apache.lucene.search.QuerygetFieldQuery(QParser parser, SchemaField field, String externalVal) Not Supported.Deprecated.getHnswM()Deprecated.org.apache.lucene.search.QuerygetKnnVectorQuery(String fieldName, String vectorToSearch, int topK, int efSearch, org.apache.lucene.search.Query filterQuery, org.apache.lucene.search.Query seedQuery, KnnQParser.EarlyTerminationParams earlyTermination, Integer filteredSearchThreshold) org.apache.lucene.search.QuerygetRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive) Not Supportedorg.apache.lucene.index.VectorSimilarityFunctionorg.apache.lucene.search.SortFieldgetSortField(SchemaField field, boolean top) Not SupportedIf DocValues is not enabled for a field, but it's indexed, docvalues can be constructed on the fly (uninverted, aka fieldcache) on the first request to sort, facet, etc.org.apache.lucene.queries.function.ValueSourcegetValueSource(SchemaField field, QParser parser) called to get the default value source (normally, from the Lucene FieldCache.)getVectorBuilder(Object inputValue, DenseVectorParser.BuilderPhase phase) Index Time Parsing The inputValue is an ArrayList with a type that depends on the loader used: -XMLLoader,CSVLoaderproduces an ArrayList of String -JsonLoaderproduces an ArrayList of Double -JavabinLoaderproduces an ArrayList of Floatorg.apache.lucene.index.VectorEncodingvoidinit(IndexSchema schema, Map<String, String> args) NOTE: This method can be removed completely whenPointField.TEST_HACK_IGNORE_USELESS_TRIEFIELD_ARGSis removedtoObject(org.apache.lucene.index.IndexableField f) Convert the stored-field format to an external object.Methods inherited from class org.apache.solr.schema.FloatPointField
getExactQuery, getPointRangeQuery, getSetQuery, getSingleValueSource, getStoredField, indexedToReadable, readableToIndexed, toNativeType, toObjectMethods inherited from class org.apache.solr.schema.PointField
getPrefixQuery, getSingleValueSource, getSpecializedRangeQuery, indexedToReadable, indexedToReadable, isFieldUsed, isPointField, isTokenized, multiValuedFieldCache, storedToIndexed, storedToReadable, toInternal, toInternalByteRef, writeMethods inherited from class org.apache.solr.schema.NumericFieldType
getDocValuesRangeQuery, getNumberType, getRangeQueryForFloatDoubleDocValues, getRangeQueryForMultiValuedDoubleDocValues, getRangeQueryForMultiValuedFloatDocValues, getSpecializedExistenceQuery, numericDocValuesRangeQuery, treatUnboundedRangeAsExistenceMethods inherited from class org.apache.solr.schema.PrimitiveFieldType
checkSupportsDocValues, getDefaultMultiValueSelectorForSortMethods inherited from class org.apache.solr.schema.FieldType
createField, getAnalyzerProperties, getClassArg, getDocValuesFormat, getExistenceQuery, getFieldTermQuery, getIndexAnalyzer, getNamedPropertyValues, getNonFieldPropertyArgs, getNumericSort, getPostingsFormat, getQueryAnalyzer, getRewriteMethod, getSimilarity, getSimilarityFactory, getSortedNumericSortField, getSortedSetSortField, getSortField, getStringSort, getTypeName, hasProperty, isExplicitAnalyzer, isExplicitQueryAnalyzer, isMultiValued, isPolyField, isUtf8Field, marshalBase64SortValue, marshalSortValue, marshalStringSortValue, readableToIndexed, restrictProps, setArgs, setIndexAnalyzer, setIsExplicitAnalyzer, setIsExplicitQueryAnalyzer, setQueryAnalyzer, setSimilarity, supportsAnalyzers, toExternal, toString, unmarshalBase64SortValue, unmarshalSortValue, unmarshalStringSortValue, useDocValuesAsStored, write
-
Field Details
-
HNSW_ALGORITHM
- See Also:
-
CAGRA_HNSW_ALGORITHM
- See Also:
-
DEFAULT_KNN_ALGORITHM
- See Also:
-
-
Constructor Details
-
DenseVectorField
public DenseVectorField() -
DenseVectorField
public DenseVectorField(int dimension) -
DenseVectorField
public DenseVectorField(int dimension, org.apache.lucene.index.VectorEncoding vectorEncoding) -
DenseVectorField
public DenseVectorField(int dimension, org.apache.lucene.index.VectorSimilarityFunction similarityFunction, org.apache.lucene.index.VectorEncoding vectorEncoding)
-
-
Method Details
-
init
Description copied from class:PointFieldNOTE: This method can be removed completely whenPointField.TEST_HACK_IGNORE_USELESS_TRIEFIELD_ARGSis removed- Overrides:
initin classPointField
-
getDimension
public int getDimension() -
getSimilarityFunction
public org.apache.lucene.index.VectorSimilarityFunction getSimilarityFunction() -
getKnnAlgorithm
-
getHnswMaxConn
Deprecated. -
getHnswBeamWidth
Deprecated. -
getHnswM
-
getHnswEfConstruction
-
getVectorEncoding
public org.apache.lucene.index.VectorEncoding getVectorEncoding() -
getCuvsWriterThreads
public int getCuvsWriterThreads() -
getCuvsIntGraphDegree
public int getCuvsIntGraphDegree() -
getCuvsGraphDegree
public int getCuvsGraphDegree() -
getCuvsHnswLayers
public int getCuvsHnswLayers() -
getCuvsHnswMaxConn
public int getCuvsHnswMaxConn() -
getCuvsHnswEfConstruction
public int getCuvsHnswEfConstruction() -
enableDocValuesByDefault
protected boolean enableDocValuesByDefault()Description copied from class:FieldTypeReturns whether this field type should enable docValues by default for schemaVersion >= 1.7. This should not be enabled for fields that did not have docValues implemented by Solr 9.7, as users may have indexed documents without docValues (since they weren't supported). Flipping the default docValues values when they upgrade to a new version will break their index compatibility.New field types can enable this without issue, as long as they support docValues.
- Overrides:
enableDocValuesByDefaultin classPrimitiveFieldType
-
checkSchemaField
Description copied from class:FieldTypeCheck'sSchemaFieldinstances constructed using this field type to ensure that they are valid.This method is called by the
SchemaFieldconstructor to check that its initialization does not violate any fundamental requirements of theFieldType. Subclasses may choose to throw aSolrExceptionif invariants are violated by theSchemaField.- Overrides:
checkSchemaFieldin classFieldType- Throws:
org.apache.solr.common.SolrException
-
createFields
Description copied from class:FieldTypeGiven aSchemaField, create one or moreIndexableFieldinstances- Overrides:
createFieldsin classPointField- Parameters:
field- theSchemaFieldvalue- The value to add to the field- Returns:
- An array of
IndexableField - See Also:
-
createField
Description copied from class:FieldTypeUsed for adding a document when a field needs to be created from a type and a string.By default, the indexed value is the same as the stored value (taken from toInternal()). Having a different representation for external, internal, and indexed would present quite a few problems given the current Lucene architecture. An analyzer for adding docs would need to translate internal->indexed while an analyzer for querying would need to translate external->indexed.
The only other alternative to having internal==indexed would be to have internal==external. In this case, toInternal should convert to the indexed representation, toExternal() should do nothing, and createField() should *not* call toInternal, but use the external value and set tokenized=true to get Lucene to convert to the internal(indexed) form. :TODO: clean up and clarify this explanation.
- Overrides:
createFieldin classFloatPointField- See Also:
-
toObject
Description copied from class:FieldTypeConvert the stored-field format to an external object.- Overrides:
toObjectin classFloatPointField- See Also:
-
getVectorBuilder
Index Time Parsing The inputValue is an ArrayList with a type that depends on the loader used: -XMLLoader,CSVLoaderproduces an ArrayList of String -JsonLoaderproduces an ArrayList of Double -JavabinLoaderproduces an ArrayList of Float -
buildKnnVectorsFormat
public org.apache.lucene.codecs.KnnVectorsFormat buildKnnVectorsFormat() -
getUninversionType
Description copied from class:FieldTypeIf DocValues is not enabled for a field, but it's indexed, docvalues can be constructed on the fly (uninverted, aka fieldcache) on the first request to sort, facet, etc. This specifies the structure to use.This method will not be used if the field is (effectively)
uninvertible="false"- Overrides:
getUninversionTypein classFloatPointField- Parameters:
sf- field instance- Returns:
- type to uninvert, or
null(to disallow uninversion for the field) - See Also:
-
getValueSource
public org.apache.lucene.queries.function.ValueSource getValueSource(SchemaField field, QParser parser) Description copied from class:FieldTypecalled to get the default value source (normally, from the Lucene FieldCache.)- Overrides:
getValueSourcein classFloatPointField
-
getKnnVectorQuery
public org.apache.lucene.search.Query getKnnVectorQuery(String fieldName, String vectorToSearch, int topK, int efSearch, org.apache.lucene.search.Query filterQuery, org.apache.lucene.search.Query seedQuery, KnnQParser.EarlyTerminationParams earlyTermination, Integer filteredSearchThreshold) -
getFieldQuery
public org.apache.lucene.search.Query getFieldQuery(QParser parser, SchemaField field, String externalVal) Not Supported. Please use the {!knn} query parser to run K nearest neighbors search queries.- Overrides:
getFieldQueryin classPointField- Parameters:
parser- TheQParsercalling the methodfield- TheSchemaFieldof the field to searchexternalVal- The String representation of the value to search- Returns:
- The
Queryinstance. This implementation returns aTermQuerybut overriding queries may not
-
getRangeQuery
public org.apache.lucene.search.Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive) Not Supported- Overrides:
getRangeQueryin classFieldType- Parameters:
parser- theQParsercalling the methodfield- the schema fieldpart1- the lower boundary of the range, nulls are allowed.part2- the upper boundary of the range, nulls are alloweminInclusive- whether the minimum of the range is inclusive or notmaxInclusive- whether the maximum of the range is inclusive or not- Returns:
- a Query instance to perform range search according to given parameters
-
getSortField
Not Supported- Overrides:
getSortFieldin classPointField- See Also:
-