Skip to content

Commit b82dd98

Browse files
committed
doc: Fix Redis metdata section
1 parent 154fc1f commit b82dd98

File tree

1 file changed

+30
-61
lines changed
  • spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs

1 file changed

+30
-61
lines changed

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

Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -108,33 +108,49 @@ You can use the following properties in your Spring Boot configuration to custom
108108

109109
== Metadata filtering
110110

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.
112112

113113
For example, you can use either the text expression language:
114114

115115
[source,java]
116116
----
117117
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"));
123123
----
124124

125-
or programmatically using the `Filter.Expression` DSL:
125+
or programmatically using the expression DSL:
126126

127127
[source,java]
128128
----
129129
FilterExpressionBuilder b = new FilterExpressionBuilder();
130130
131-
vectorStore.similaritySearch(SearchRequest.defaults()
132-
.withQuery("The World")
133-
.withTopK(TOP_K)
134-
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
135-
.withFilterExpression(b.and(
136-
b.in("author", "john", "jill"),
137-
b.eq("article_type", "blog")).build()));
131+
vectorStore.similaritySearch(
132+
SearchRequest
133+
.query("The World")
134+
.withTopK(TOP_K)
135+
.withSimilarityThreshold(SIMILARITY_THRESHOLD)
136+
.withFilterExpression(b.and(
137+
b.in("country", "UK", "NL"),
138+
b.gte("year", 2020)).build()));
139+
----
140+
141+
The portable filter expressions get automatically converted into link:https://redis.io/docs/interact/search-and-query/query/[Redis search queries].
142+
For example, the following portable filter expression:
143+
144+
[source,sql]
145+
----
146+
country in ['UK', 'NL'] && year >= 2020
147+
----
148+
149+
is converted into Redis query:
150+
151+
[source]
152+
----
153+
@country:{UK | NL} @year:[2020 inf]
138154
----
139155

140156
== Manual configuration
@@ -218,50 +234,3 @@ List<Document> results = vectorStore.similaritySearch(
218234
----
219235

220236
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:
256-
257-
[source,sql]
258-
----
259-
country in ['UK', 'NL'] && year >= 2020
260-
----
261-
262-
is converted into Redis query:
263-
264-
[source]
265-
----
266-
@country:{UK | NL} @year:[2020 inf]
267-
----

0 commit comments

Comments
 (0)