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
Remove @Nullable from VectorStore similaritySearch (#3613)
The VectorStore#similaritySearch methods never return null, but there's
a data flow issue in AbstractObservationVectorStore caused by Micrometer's
Observation#observe being marked as @nullable. The returned value is
actually controlled by Spring AI's supplier, which never returns null.
Fixes#3613
Auto-cherry-pick to 1.0.x
Signed-off-by: Filip Hrisafov <[email protected]>
Copy file name to clipboardExpand all lines: spring-ai-vector-store/src/main/java/org/springframework/ai/vectorstore/observation/AbstractObservationVectorStore.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -111,7 +111,9 @@ public void delete(Filter.Expression filterExpression) {
111
111
}
112
112
113
113
@Override
114
-
@Nullable
114
+
// Micrometer Observation#observe returns the value of the Supplier, which is never
Copy file name to clipboardExpand all lines: vector-stores/spring-ai-azure-cosmos-db-store/src/main/java/org/springframework/ai/vectorstore/cosmosdb/CosmosDBVectorStore.java
+1-3Lines changed: 1 addition & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -434,15 +434,13 @@ public List<Document> doSimilaritySearch(SearchRequest request) {
434
434
}
435
435
436
436
// Convert JsonNode to Document
437
-
List<Document> docs =documents.stream()
437
+
returndocuments.stream()
438
438
.map(doc -> Document.builder()
439
439
.id(doc.get("id").asText())
440
440
.text(doc.get("content").asText())
441
441
.metadata(docFields)
442
442
.build())
443
443
.collect(Collectors.toList());
444
-
445
-
returndocs != null ? docs : List.of();
446
444
}
447
445
catch (Exceptione) {
448
446
logger.error("Error during similarity search: {}", e.getMessage());
Copy file name to clipboardExpand all lines: vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/chroma/vectorstore/ChromaVectorStore.java
Copy file name to clipboardExpand all lines: vector-stores/spring-ai-gemfire-store/src/main/java/org/springframework/ai/vectorstore/gemfire/GemFireVectorStore.java
-1Lines changed: 0 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -243,7 +243,6 @@ public void doDelete(List<String> idList) {
0 commit comments