Skip to content

Commit 754dab9

Browse files
committed
Add minimal (placeholder) MongoDB Atlas Vector Serach docs.
1 parent eea3801 commit 754dab9

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/nav.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
*** xref:api/vectordbs/chroma.adoc[]
5151
*** xref:api/vectordbs/gemfire.adoc[GemFire]
5252
*** xref:api/vectordbs/milvus.adoc[]
53+
*** xref:api/vectordbs/mongodb.adoc[]
5354
*** xref:api/vectordbs/neo4j.adoc[]
5455
*** xref:api/vectordbs/pgvector.adoc[]
5556
*** xref:api/vectordbs/pinecone.adoc[]
@@ -58,6 +59,7 @@
5859
*** xref:api/vectordbs/hana.adoc[SAP Hana]
5960
*** xref:api/vectordbs/weaviate.adoc[]
6061
62+
6163
** xref:api/functions.adoc[Function Calling]
6264
** xref:api/prompt.adoc[]
6365
** xref:api/output-parser.adoc[]

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ These are the available implementations of the `VectorStore` interface:
9292
* xref:api/vectordbs/chroma.adoc[Chroma Vector Store] - The https://www.trychroma.com/[Chroma] vector store.
9393
* xref:api/vectordbs/gemfire.adoc[GemFire Vector Store] - The https://tanzu.vmware.com/content/blog/vmware-gemfire-vector-database-extension[GemFire] vector store.
9494
* xref:api/vectordbs/milvus.adoc[Milvus Vector Store] - The https://milvus.io/[Milvus] vector store.
95+
* xref:api/vectordbs/mongodb.adoc[MongoDB Atlas Vector Store] - The https://www.mongodb.com/atlas/database[MongoDB Atlas] vector store.
9596
* xref:api/vectordbs/neo4j.adoc[Neo4j Vector Store] - The https://neo4j.com/[Neo4j] vector store.
9697
* xref:api/vectordbs/pgvector.adoc[PgVectorStore] - The https://github.com/pgvector/pgvector[PostgreSQL/PGVector] vector store.
9798
* xref:api/vectordbs/pinecone.adoc[Pinecone Vector Store] - https://www.pinecone.io/[PineCone] vector store.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
= MongoDB Atlas
2+
3+
WIP: Please consider contributing docs: https://github.com/spring-projects/spring-ai/issues/456[Add documentation for the MongoDB Atlas Vector Store]
4+
5+
https://www.mongodb.com/basics/vector-databases[MongoDB Atlas Vector Search] is a fully managed cloud database service that provides the easiest way to deploy, operate, and scale a MongoDB database in the cloud.
6+
7+
== Prerequisites
8+
9+
TODO: Add prerequisites instructions
10+
11+
== Auto-configuration
12+
13+
Spring AI provides Spring Boot auto-configuration for the MongoDB Atlas Vector Sore.
14+
To enable it, add the following dependency to your project's Maven `pom.xml` file:
15+
16+
[source, xml]
17+
----
18+
<dependency>
19+
<groupId>org.springframework.ai</groupId>
20+
<artifactId>spring-ai-mongodb-atlas-store-spring-boot-starter</artifactId>
21+
</dependency>
22+
----
23+
24+
or to your Gradle `build.gradle` build file.
25+
26+
[source,groovy]
27+
----
28+
dependencies {
29+
implementation 'org.springframework.ai:spring-ai-mongodb-atlas-store-spring-boot-starter'
30+
}
31+
----
32+
33+
TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Management] section to add the Spring AI BOM to your build file.
34+
35+
TIP: Refer to the xref:getting-started.adoc#repositories[Repositories] section to add Milestone and/or Snapshot Repositories to your build file.
36+
37+
Additionally, you will need a configured `EmbeddingClient` bean. Refer to the xref:api/embeddings.adoc#available-implementations[EmbeddingClient] section for more information.
38+
39+
Here is an example of the needed bean:
40+
41+
[source,java]
42+
----
43+
@Bean
44+
public EmbeddingClient embeddingClient() {
45+
// Can be any other EmbeddingClient implementation.
46+
return new OpenAiEmbeddingClient(new OpenAiApi(System.getenv("SPRING_AI_OPENAI_API_KEY")));
47+
}
48+
----
49+
50+
== Metadata filtering
51+
52+
You can leverage the generic, portable xref:api/vectordbs.adoc#metadata-filters[metadata filters] with MongoDB Atlas store as well.
53+
54+
For example, you can use either the text expression language:
55+
56+
[source,java]
57+
----
58+
vectorStore.similaritySearch(
59+
SearchRequest.defaults()
60+
.withQuery("The World")
61+
.withTopK(TOP_K)
62+
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
63+
.withFilterExpression("author in ['john', 'jill'] && 'article_type' == 'blog'"));
64+
----
65+
66+
or programmatically using the `Filter.Expression` DSL:
67+
68+
[source,java]
69+
----
70+
FilterExpressionBuilder b = new FilterExpressionBuilder();
71+
72+
vectorStore.similaritySearch(SearchRequest.defaults()
73+
.withQuery("The World")
74+
.withTopK(TOP_K)
75+
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
76+
.withFilterExpression(b.and(
77+
b.in("john", "jill"),
78+
b.eq("article_type", "blog")).build()));
79+
----
80+
81+
NOTE: Those (portable) filter expressions get automatically converted into the proprietary MongoDB Atlas filter expressions.
82+
83+
== MongoDB Atlas properties
84+
85+
You can use the following properties in your Spring Boot configuration to customize the MongoDB Atlas vector store.
86+
87+
|===
88+
|Property| Description | Default value
89+
90+
|`spring.ai.vectorstore.mongodb.collection-name`| The name of the collection to store the vectors. | `vector_store`
91+
|`spring.ai.vectorstore.mongodb.path-name`| The name of the path to store the vectors. | `embedding`
92+
|`spring.ai.vectorstore.mongodb.indexName`| The name of the index to store the vectors. | `vector_index`
93+
|===

0 commit comments

Comments
 (0)