You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/qdrant.adoc
+34-52Lines changed: 34 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -9,32 +9,20 @@ link:https://www.qdrant.tech/[Qdrant] is an open-source, high-performance vector
9
9
* Qdrant Instance: Set up a Qdrant instance by following the link:https://qdrant.tech/documentation/guides/installation/[installation instructions] in the Qdrant documentation.
10
10
* If required, an API key for the xref:api/embeddings.adoc#available-implementations[EmbeddingClient] to generate the embeddings stored by the `QdrantVectorStore`.
11
11
12
-
== Configuration
12
+
To set up `QdrantVectorStore`, you'll need the following information from your Qdrant instance: `Host`, `GRPC Port`, `Collection Name`, and `API Key` (if required).
13
13
14
-
To set up `QdrantVectorStore`, you'll need the following information from your Qdrant instance:
15
-
16
-
* Qdrant Host
17
-
* Qdrant GRPC Port
18
-
* Qdrant Collection Name
19
-
* Optional Qdrant API Key (not required for local development)
20
-
21
-
[NOTE]
22
-
====
23
-
A Qdrant collection has to be link:https://qdrant.tech/documentation/concepts/collections/#create-a-collection[created] in advance with the appropriate dimensions and configurations.
24
-
25
-
For example if using the OpenAI `text-embedding-ada-002` embedding model, create a collection with a vector size of `1536`.
26
-
====
14
+
NOTE: It is recommended that the Qdrant collection is link:https://qdrant.tech/documentation/concepts/collections/#create-a-collection[created] in advance with the appropriate dimensions and configurations.
15
+
If the collection is not created, the `QdrantVectorStore` will attempt to create one using the `Cosine` similarity and the dimension of the configured `EmbeddingClient`.
27
16
28
17
== Dependencies
29
18
30
-
* The Vector Store requires an `EmbeddingClient` instance to calculate embeddings for the documents.
31
-
You can pick one of the available xref:api/embeddings.adoc#available-implementations[EmbeddingClient Implementations]. For example ou can use the OpenAI boot starter:
19
+
Then add the Qdrant boot starter dependency to your project:
TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Management] section to add the Spring AI BOM to your build file.
61
+
Refer to the xref:getting-started.adoc#repositories[Repositories] section to add Milestone and/or Snapshot Repositories to your build file.
62
+
63
+
To connect to Qdrant and use the `QdrantVectorStore`, you need to provide access details for your instance.
64
+
A simple configuration can either be provided via Spring Boot's _application.properties_,
74
65
75
-
Please have a look at the list of xref:#qdrant-vectorstore-properties[configuration parameters] for the vector store to learn about the default values and configuration options.
66
+
[source,properties]
67
+
----
68
+
spring.ai.vectorstore.qdrant.host=<host of your qdrant instance>
69
+
spring.ai.vectorstore.qdrant.port=<the GRPC port of your qdrant instance>
70
+
spring.ai.vectorstore.qdrant.api-key=<your api key>
71
+
spring.ai.vectorstore.qdrant.collection-name=<The name of the collection to use in Qdrant>
76
72
77
-
TIP: Refer to the xref:getting-started.adoc#repositories[Repositories] section to add Milestone and/or Snapshot Repositories to your build file.
73
+
# API key if needed, e.g. OpenAI
74
+
spring.ai.openai.api.key=<api-key>
75
+
----
78
76
77
+
TIP: Check the list of xref:#qdrant-vectorstore-properties[configuration parameters] to learn about the default values and configuration options.
79
78
80
79
Now you can Auto-wire the Qdrant Vector Store in your application and use it
81
80
82
81
[source,java]
83
82
----
84
-
@Autowired
85
-
VectorStore vectorStore;
83
+
@Autowired VectorStore vectorStore;
84
+
85
+
// ...
86
86
87
-
...
88
87
List <Document> documents = List.of(
89
88
new Document("Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!", Map.of("meta1", "meta1")),
90
89
new Document("The World is Big and Salvation Lurks Around the Corner"),
To connect to Qdrant and use the `QdrantVectorStore`, you need to provide access details for your instance.
103
-
A simple configuration can either be provided via Spring Boot's _application.properties_,
104
-
105
-
[source,properties]
106
-
----
107
-
spring.ai.vectorstore.qdrant.host=<host of your qdrant instance>
108
-
spring.ai.vectorstore.qdrant.port=<port of your qdrant instance>
109
-
spring.ai.vectorstore.qdrant.api-key=<your api key>
110
-
spring.ai.vectorstore.qdrant.collection-name=<The name of the collection to use in Qdrant>
111
-
112
-
# API key if needed, e.g. OpenAI
113
-
spring.ai.openai.api.key=<api-key>
114
-
----
115
-
116
-
117
-
== Manual Configuration
99
+
=== Manual Configuration
118
100
119
101
Instead of using the Spring Boot auto-configuration, you can manually configure the `QdrantVectorStore`. For this you need to add the `spring-ai-qdrant` dependency to your project:
120
102
@@ -162,7 +144,7 @@ public VectorStore vectorStore(QdrantVectorStoreConfig config, EmbeddingClient e
162
144
}
163
145
----
164
146
165
-
=== Metadata filtering
147
+
== Metadata filtering
166
148
167
149
You can leverage the generic, portable link:https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_metadata_filters[metadata filters] with the Qdrant vector store.
Copy file name to clipboardExpand all lines: spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/qdrant/QdrantVectorStoreAutoConfiguration.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ public VectorStore vectorStore(EmbeddingClient embeddingClient, QdrantVectorStor
Copy file name to clipboardExpand all lines: spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/qdrant/QdrantVectorStoreProperties.java
Copy file name to clipboardExpand all lines: spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/vectorstore/qdrant/QdrantVectorStoreAutoConfigurationIT.java
+10-27Lines changed: 10 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -54,8 +54,6 @@ public class QdrantVectorStoreAutoConfigurationIT {
0 commit comments