Skip to content

1.1.2 Differences in results when adding vector data to Redis using new Document() and Document.builder() #5117

@lhf2003

Description

@lhf2003

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

  1. The vector data created using new Document can be searched for using vectorStore.similaritySearch.
    Document document = new Document(UUID.randomUUID().toString(), request,
            Map.of("response", stringBuilder.toString(),
                    "userId", userId.toString()));
  1. 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);
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions