Class MongoDbEmbeddingStore.Builder

java.lang.Object
dev.langchain4j.store.embedding.mongodb.MongoDbEmbeddingStore.Builder
Enclosing class:
MongoDbEmbeddingStore

public static class MongoDbEmbeddingStore.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • fromClient

      public MongoDbEmbeddingStore.Builder fromClient(com.mongodb.client.MongoClient mongoClient)
      Build Mongo Client, Please close the client to release resources after usage
    • databaseName

      public MongoDbEmbeddingStore.Builder databaseName(String databaseName)
    • collectionName

      public MongoDbEmbeddingStore.Builder collectionName(String collectionName)
    • indexName

      public MongoDbEmbeddingStore.Builder indexName(String indexName)
    • maxResultRatio

      public MongoDbEmbeddingStore.Builder maxResultRatio(Long maxResultRatio)
    • createCollectionOptions

      public MongoDbEmbeddingStore.Builder createCollectionOptions(com.mongodb.client.model.CreateCollectionOptions createCollectionOptions)
    • filter

      public MongoDbEmbeddingStore.Builder filter(org.bson.conversions.Bson filter)
      Document query filter, all fields included in filter must be contained in IndexMapping.metadataFieldNames

      For example:

      • AND filter: Filters.and(Filters.in("type", asList("TXT", "md")), Filters.eqFull("test-key", "test-value"))
      • OR filter: Filters.or(Filters.in("type", asList("TXT", "md")), Filters.eqFull("test-key", "test-value"))
      Parameters:
      filter - document query filter
      Returns:
      builder
    • indexMapping

      public MongoDbEmbeddingStore.Builder indexMapping(IndexMapping indexMapping)
      set MongoDB search index fields mapping

      if createIndex is true, then indexMapping not work

      Parameters:
      indexMapping - MongoDB search index fields mapping
      Returns:
      builder
    • createIndex

      public MongoDbEmbeddingStore.Builder createIndex(Boolean createIndex)
      Set whether in production mode, production mode will not create index automatically

      default value is false

      Parameters:
      createIndex - whether in production mode
      Returns:
      builder
    • build

      public MongoDbEmbeddingStore build()