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/embeddings.adoc
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -146,7 +146,7 @@ public class Embedding implements ModelResult<List<Double>> {
146
146
}
147
147
----
148
148
149
-
== Available Implementations
149
+
== Available Implementations [[available-implementations]]
150
150
151
151
Internally the various `EmbeddingClient` implementations use different low-level libraries and APIs to perform the embedding tasks. The following are some of the available implementations of the `EmbeddingClient` implementations:
This section walks you through setting up `Neo4jVectorStore` to store document embeddings and perform similarity searches.
4
4
5
-
== What is Neo4j?
5
+
link:https://neo4j.com[Neo4j] is an open-source NoSQL graph database.
6
+
It is a fully transactional database (ACID) that stores data structured as graphs consisting of nodes, connected by relationships.
7
+
Inspired by the structure of the real world, it allows for high query performance on complex data while remaining intuitive and simple for the developer.
6
8
7
-
link:https://neo4j.com[Neo4j] is an open-source NoSQL graph database. It is a fully transactional database (ACID) that stores data structured as graphs consisting of nodes, connected by relationships. Inspired by the structure of the real world, it allows for high query performance on complex data while remaining intuitive and simple for the developer.
9
+
The link:https://neo4j.com/docs/cypher-manual/current/indexes-for-vector-search/[Neo4j's Vector Search] allows users to query vector embeddings from large datasets. An embedding is a numerical representation of a data object, such as text, image, audio, or document.
10
+
Embeddings can be stored on _Node_ properties and can be queried with the `db.index.vector.queryNodes()` function.
11
+
Those indexes are powered by Lucene using a Hierarchical Navigable Small World Graph (HNSW) to perform a k approximate nearest neighbors (k-ANN) query over the vector fields.
8
12
9
-
== What is Neo4j Vector Search?
13
+
== Prerequisites
10
14
11
-
link:https://neo4j.com/docs/cypher-manual/current/indexes-for-vector-search/[Neo4j's Vector Search] got introduced in Neo4j 5.11 and was considered GA with the release of version 5.13. Embeddings can be stored on _Node_ properties and can be queried with the `db.index.vector.queryNodes()` function. Those indexes are powered by Lucene using a Hierarchical Navigable Small World Graph (HNSW) to perform a k approximate nearest neighbors (k-ANN) query over the vector fields.
12
-
13
-
=== Prerequisites
14
-
15
-
1. OpenAI Account: Create an account at link:https://platform.openai.com/signup[OpenAI Signup] and generate the token at link:https://platform.openai.com/account/api-keys[API Keys].
16
-
17
-
2. A running Neo4j (5.13+) instance
18
-
a. link:https://hub.docker.com/_/neo4j[Docker] image _neo4j:5.15_
19
-
b. link:https://neo4j.com/download/[Neo4j Desktop]
20
-
c. link:https://neo4j.com/cloud/aura-free/[Neo4j Aura]
21
-
d. link:https://neo4j.com/deployment-center/[Neo4j Server] instance
15
+
* You would need an xref:api/embeddings.adoc#available-implementations[EmbeddingClient] to generate the embeddings stored in the `Neo4jVectorStore`.
16
+
* A running Neo4j (5.13+) instance. Following options are available:
TIP: Refer to the xref:getting-started.adoc#_dependency_management[Dependency Management] section to add Milestone and/or Snapshot Repositories to your build file.
51
+
76
52
== Sample Code
77
53
78
54
To configure `Neo4jVectorStore` in your application, you can use the following setup:
@@ -92,18 +68,19 @@ You'll need a `VectorStore` to store the embeddings. You can use the `Neo4jVecto
92
68
93
69
[source,java]
94
70
----
71
+
@Bean
72
+
public EmbeddingClient embeddingClient() {
73
+
// Can be any other EmbeddingClient implementation.
74
+
return new OpenAiEmbeddingClient(new OpenAiApi(System.getenv("SPRING_AI_OPENAI_API_KEY")));
NOTE: Those (portable) filter expressions get automatically converted into the proprietary Neo4j `WHERE` link:https://neo4j.com/developer/cypher/filtering-query-results/[filter expressions].
125
+
126
+
For example, this portable filter expression:
127
+
128
+
```sql
129
+
author in ['john', 'jill'] && 'article_type' == 'blog'
130
+
```
131
+
132
+
is converted into the proprietary Neo4j filter format:
133
+
134
+
```
135
+
node.`metadata.author` IN ["john","jill"] AND node.`metadata.'article_type'` = "blog"
136
+
```
137
+
138
+
== Auto-configuration
139
+
140
+
Spring AI provides Spring Boot auto-configuration for the Neo4j Vector Sore.
141
+
To enable it add the following dependency to your project's Maven `pom.xml` file:
TIP: Additionally, you will need a configured `EmbeddingClient` bean. Refer to the xref:api/embeddings.adoc#available-implementations[EmbeddingClient] section for more information.
162
+
163
+
TIP: Refer to the xref:getting-started.adoc#_dependency_management[Dependency Management] section to add Milestone and/or Snapshot Repositories to your build file.
164
+
165
+
Now you can auto-wire the `Neo4jVectorStore` as a vector store in your application.
Copy file name to clipboardExpand all lines: spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/neo4j/Neo4jVectorStoreProperties.java
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -40,39 +40,39 @@ public class Neo4jVectorStoreProperties {
Copy file name to clipboardExpand all lines: vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java
0 commit comments