@@ -65,7 +65,7 @@ public RestTemplate restTemplate() {
65
65
@Bean
66
66
public ChromaApi chromaApi(RestTemplate restTemplate) {
67
67
String chromaUrl = "http://localhost:8000";
68
- ChromaApi chromaApi = ChromaApi(chromaUrl, restTemplate);
68
+ ChromaApi chromaApi = new ChromaApi(chromaUrl, restTemplate);
69
69
return chromaApi;
70
70
}
71
71
----
@@ -101,14 +101,14 @@ Add the documents to your vector store:
101
101
102
102
[source,java]
103
103
----
104
- vectorStore.add(List.of(document) );
104
+ vectorStore.add(documents );
105
105
----
106
106
107
107
And finally, retrieve documents similar to a query:
108
108
109
109
[source,java]
110
110
----
111
- List<Document> results = vectorStore.similaritySearch("Spring", 5 );
111
+ List<Document> results = vectorStore.similaritySearch("Spring");
112
112
----
113
113
114
114
If all goes well, you should retrieve the document containing the text "Spring AI rocks!!".
@@ -121,8 +121,12 @@ For example, you can use either the text expression language:
121
121
122
122
[source,java]
123
123
----
124
- vectorStore.similaritySearch("The World", TOP_K, SIMILARITY_THRESHOLD,
125
- "author in ['john', 'jill'] && article_type == 'blog'");
124
+ vectorStore.similaritySearch(
125
+ SearchRequest.defaults()
126
+ .withQuery("The World")
127
+ .withTopK(TOP_K)
128
+ .withSimilarityThreshold(SIMILARITY_THRESHOLD)
129
+ .withFilterExpression("author in ['john', 'jill'] && article_type == 'blog'"));
126
130
----
127
131
128
132
or programmatically using the `Filter.Expression` DSL:
@@ -131,10 +135,13 @@ or programmatically using the `Filter.Expression` DSL:
131
135
----
132
136
FilterExpressionBuilder b = new FilterExpressionBuilder();
133
137
134
- vectorStore.similaritySearch("The World", TOP_K, SIMILARITY_THRESHOLD,
135
- b.and(
136
- b.in(List.of("john", "jill")),
137
- b.eq("article_type", "blog")).build());
138
+ vectorStore.similaritySearch(SearchRequest.defaults()
139
+ .withQuery("The World")
140
+ .withTopK(TOP_K)
141
+ .withSimilarityThreshold(SIMILARITY_THRESHOLD)
142
+ .withFilterExpression(b.and(
143
+ b.in("john", "jill"),
144
+ b.eq("article_type", "blog")).build()));
138
145
----
139
146
140
147
NOTE: Those (portable) filter expressions get automatically converted into the proprietary Chroma `where` link:https://docs.trychroma.com/usage-guide#using-where-filters[filter expressions].
0 commit comments