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/redis.adoc
+30-61Lines changed: 30 additions & 61 deletions
Original file line number
Diff line number
Diff line change
@@ -108,33 +108,49 @@ You can use the following properties in your Spring Boot configuration to custom
108
108
109
109
== Metadata filtering
110
110
111
-
You can leverage the generic, portable link:https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_metadata_filters[metadata filters] with the Redis vector store.
111
+
You can leverage the generic, portable link:https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_metadata_filters[metadata filters] with RedisVectorStore as well.
112
112
113
113
For example, you can use either the text expression language:
114
114
115
115
[source,java]
116
116
----
117
117
vectorStore.similaritySearch(
118
-
SearchRequest.defaults()
119
-
.withQuery("The World")
120
-
.withTopK(TOP_K)
121
-
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
122
-
.withFilterExpression("author in ['john', 'jill'] && article_type == 'blog'"));
118
+
SearchRequest
119
+
.query("The World")
120
+
.withTopK(TOP_K)
121
+
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
122
+
.withFilterExpression("country in ['UK', 'NL'] && year >= 2020"));
123
123
----
124
124
125
-
or programmatically using the `Filter.Expression` DSL:
125
+
or programmatically using the expression DSL:
126
126
127
127
[source,java]
128
128
----
129
129
FilterExpressionBuilder b = new FilterExpressionBuilder();
If all goes well, you should retrieve the document containing the text "Spring AI rocks!!".
221
-
222
-
=== Metadata filtering
223
-
224
-
You can leverage the generic, portable link:https://docs.spring.io/spring-ai/reference/api/vectordbs.html#_metadata_filters[metadata filters] with RedisVectorStore as well.
225
-
226
-
For example, you can use either the text expression language:
227
-
228
-
[source,java]
229
-
----
230
-
vectorStore.similaritySearch(
231
-
SearchRequest
232
-
.query("The World")
233
-
.withTopK(TOP_K)
234
-
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
235
-
.withFilterExpression("country in ['UK', 'NL'] && year >= 2020"));
236
-
----
237
-
238
-
or programmatically using the expression DSL:
239
-
240
-
[source,java]
241
-
----
242
-
FilterExpressionBuilder b = new FilterExpressionBuilder();
243
-
244
-
vectorStore.similaritySearch(
245
-
SearchRequest
246
-
.query("The World")
247
-
.withTopK(TOP_K)
248
-
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
249
-
.withFilterExpression(b.and(
250
-
b.in("country", "UK", "NL"),
251
-
b.gte("year", 2020)).build()));
252
-
----
253
-
254
-
The portable filter expressions get automatically converted into link:https://redis.io/docs/interact/search-and-query/query/[Redis search queries].
255
-
For example, the following portable filter expression:
0 commit comments