-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Bug description
Differences in results when adding vector data to Redis using new Document() and Document.builder()
Environment
<spring-ai.version>1.1.2</spring-ai.version>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-redis-store</artifactId>
</dependency>Steps to reproduce
- The vector data created using
new Documentcan be searched for usingvectorStore.similaritySearch.
Document document = new Document(UUID.randomUUID().toString(), request,
Map.of("response", stringBuilder.toString(),
"userId", userId.toString()));- However, the vector data added using Document.builder cannot be queried.
Document document = Document.builder()
.id(UUID.randomUUID().toString())
.metadata(Map.of("userId", userId, "response", stringBuilder.toString()))
.text(request)
.build();Minimal Complete Reproducible example
@Test
public void addTest() {
Document document = new Document(UUID.randomUUID().toString(), "Hello",
Map.of("response", "Hello,How can I help you?",
"userId", "6"));
vectorStore.add(List.of(document));
}
/**
* Can't be searched
*/
@Test
public void addTest2() {
Document document = Document.builder()
.id(UUID.randomUUID().toString())
.metadata(Map.of("userId", "6",
"response","Hello,How can I help you?"))
.text("Hello")
.build();
vectorStore.add(List.of(document));
}
@Test
void searchTest() {
List<Document> documents = vectorStore.similaritySearch("Hello");
documents.forEach(System.out::println);
}