Package com.mongodb.client.model
Class HnswSearchIndexOptions
java.lang.Object
com.mongodb.client.model.HnswSearchIndexOptions
- All Implemented Interfaces:
Bson
Options for the HNSW (Hierarchical Navigable Small World) indexing method in a vector search index.
This class provides a fluent builder for specifying HNSW-specific parameters when creating
a vector search index with indexingMethod("hnsw").
Since VectorSearchIndexFields.VectorField.hnswOptions(Bson) accepts any Bson,
a raw Document may also be passed directly for forward compatibility.
vectorField("embedding")
.indexingMethod("hnsw")
.hnswOptions(new HnswSearchIndexOptions().maxEdges(16).numEdgeCandidates(200))
- Since:
- 5.8
- See Also:
-
Field Summary
Fields inherited from interface org.bson.conversions.Bson
DEFAULT_CODEC_REGISTRY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionmaxEdges(int maxEdges) Sets the maximum number of connected neighbors for each node in the HNSW graph.numEdgeCandidates(int numEdgeCandidates) Sets the number of nearest neighbor candidates to consider when building the HNSW graph.<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
-
Constructor Details
-
HnswSearchIndexOptions
public HnswSearchIndexOptions()Creates a new instance with default settings.- Since:
- 5.8
-
-
Method Details
-
maxEdges
Sets the maximum number of connected neighbors for each node in the HNSW graph.- Parameters:
maxEdges- the maximum number of edges (connected neighbors)- Returns:
- this
- Since:
- 5.8
-
numEdgeCandidates
Sets the number of nearest neighbor candidates to consider when building the HNSW graph.- Parameters:
numEdgeCandidates- the number of nearest neighbor candidates- Returns:
- this
- Since:
- 5.8
-
toBsonDocument
public <TDocument> BsonDocument toBsonDocument(Class<TDocument> documentClass, CodecRegistry codecRegistry) - Specified by:
toBsonDocumentin interfaceBson
-
toString
-