Package com.mongodb.client.model
Class VectorSearchIndexFields.VectorField
java.lang.Object
com.mongodb.client.model.VectorSearchIndexFields.VectorField
- All Implemented Interfaces:
Bson
- Enclosing class:
- VectorSearchIndexFields
@NotThreadSafe
public static final class VectorSearchIndexFields.VectorField
extends Object
implements Bson
A vector field definition for a vector search index.
Instances are created via VectorSearchIndexFields.vectorField(String).
- Since:
- 5.8
-
Field Summary
Fields inherited from interface org.bson.conversions.Bson
DEFAULT_CODEC_REGISTRY -
Method Summary
Modifier and TypeMethodDescriptionhnswOptions(Bson hnswOptions) Sets the HNSW options for this vector field.indexingMethod(String indexingMethod) Sets the indexing method for this vector field.numDimensions(int numDimensions) Sets the number of dimensions for the vector field.similarity(String similarity) Sets the similarity function used to compare vectors.<TDocument>
BsonDocumenttoBsonDocument(Class<TDocument> documentClass, CodecRegistry codecRegistry) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bson.conversions.Bson
toBsonDocument
-
Method Details
-
numDimensions
Sets the number of dimensions for the vector field.- Parameters:
numDimensions- the number of vector dimensions- Returns:
- this
- Since:
- 5.8
-
similarity
Sets the similarity function used to compare vectors.Supported values:
"euclidean"— measures the distance between ends of vectors"cosine"— measures the angle between vectors"dotProduct"— measures both the magnitude and direction of vectors
- Parameters:
similarity- the similarity function name- Returns:
- this
- Since:
- 5.8
-
indexingMethod
Sets the indexing method for this vector field.Supported values:
"flat"— optimized for multi-tenant use cases with singular, static filters"hnsw"— Hierarchical Navigable Small World graph
- Parameters:
indexingMethod- the indexing method name- Returns:
- this
- Since:
- 5.8
-
hnswOptions
Sets the HNSW options for this vector field.This is only applicable when the indexing method is
"hnsw". A convenience builder is available viaHnswSearchIndexOptions, or a rawDocumentmay be passed directly.- Parameters:
hnswOptions- the HNSW options- Returns:
- this
- Since:
- 5.8
- See Also:
-
toBsonDocument
public <TDocument> BsonDocument toBsonDocument(Class<TDocument> documentClass, CodecRegistry codecRegistry) - Specified by:
toBsonDocumentin interfaceBson
-
toString
-