Class VectorSearchIndexFields.AutoEmbedField

java.lang.Object
com.mongodb.client.model.VectorSearchIndexFields.AutoEmbedField
All Implemented Interfaces:
Bson
Enclosing class:
VectorSearchIndexFields

@NotThreadSafe public static final class VectorSearchIndexFields.AutoEmbedField extends Object implements Bson
An auto-embed field definition for a vector search index.

Instances are created via VectorSearchIndexFields.autoEmbedField(String).

Since:
5.8
  • Method Details

    • modality

      public VectorSearchIndexFields.AutoEmbedField modality(String modality)
      Sets the modality for auto-embedding. This is a required field.

      The initially supported type is "text".

      Parameters:
      modality - the modality (e.g., "text")
      Returns:
      this
      Since:
      5.8
    • model

      Sets the embedding model to use. This is a required field.

      Only one model can be used across all fields in a single vector index definition.

      Parameters:
      model - the model name (e.g., "voyage-4", "voyage-4-large", "voyage-4-lite", "voyage-code-3")
      Returns:
      this
      Since:
      5.8
    • numDimensions

      public VectorSearchIndexFields.AutoEmbedField numDimensions(int numDimensions)
      Sets the number of dimensions for the auto-embedded vector. This is an optional field.

      These map to the number of dimensions supported by the API endpoint (currently 256, 512, 1024, 2048).

      Parameters:
      numDimensions - the number of vector dimensions
      Returns:
      this
      Since:
      5.8
    • quantization

      public VectorSearchIndexFields.AutoEmbedField quantization(String quantization)
      Sets the quantization type for the auto-embedded vector. This is an optional field.

      Supported values:

      • "float"
      • "scalar"
      • "binary"
      • "binaryNoRescore"
      Parameters:
      quantization - the quantization type
      Returns:
      this
      Since:
      5.8
    • similarity

      public VectorSearchIndexFields.AutoEmbedField similarity(String similarity)
      Sets the similarity function used to compare vectors. This is an optional field.

      Supported values:

      • "dotProduct"
      • "cosine"
      • "euclidean"
      Parameters:
      similarity - the similarity function name
      Returns:
      this
      Since:
      5.8
    • indexingMethod

      public VectorSearchIndexFields.AutoEmbedField indexingMethod(String indexingMethod)
      Sets the indexing method for this auto-embed field. This is an optional 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

      public VectorSearchIndexFields.AutoEmbedField hnswOptions(Bson hnswOptions)
      Sets the HNSW options for this auto-embed field. This is an optional field.

      This is only applicable when the indexing method is "hnsw". A convenience builder is available via HnswSearchIndexOptions, or a raw Document may 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:
      toBsonDocument in interface Bson
    • toString

      public String toString()
      Overrides:
      toString in class Object