Skip to content

redis vectorset embedding store#477

Draft
Jacopo47 wants to merge 9 commits intolangchain4j:mainfrom
Jacopo47:feature/393-redis-vectorset-embedding-store
Draft

redis vectorset embedding store#477
Jacopo47 wants to merge 9 commits intolangchain4j:mainfrom
Jacopo47:feature/393-redis-vectorset-embedding-store

Conversation

@Jacopo47
Copy link

Issue

Closes #393

Change

General checklist

  • There are no breaking changes
  • I have added unit and integration tests for my change
  • I have manually run all the unit tests in all modules, and they are all green
  • I have manually run all integration tests in the module I have added/changed, and they are all green

Checklist for adding new maven module

  • I have added my new module in the root pom.xml and langchain4j-community-bom/pom.xml

Checklist for adding new embedding store integration

  • I have added a {NameOfIntegration}EmbeddingStoreIT that extends from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT
  • I have added a {NameOfIntegration}EmbeddingStoreRemovalIT that extends from EmbeddingStoreWithRemovalIT

Checklist for changing existing embedding store integration

  • I have manually verified that the {NameOfIntegration}EmbeddingStore works correctly with the data persisted using the latest released version of LangChain4j

@Martin7-1
Copy link
Collaborator

@Jacopo47 Thanks for the great work! I'm wondering if we should use UnifiedJedis as the client like RedisEmbeddingStore?

Copy link
Collaborator

@Martin7-1 Martin7-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jacopo47 Thank you!

Could you please add Builder pattern and some javadoc in the constructor and class to clarify the meaing of parameters in the constructor.

BTW, to make spotless happy, please run make format. Thank you!


import java.util.UUID;

class RedisVectorSetsEmbeddingStoreRemovalIT extends EmbeddingStoreWithRemovalIT {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy-paste issue in filename, should be RedisVectorSetsEmbeddingStoreRemovalIT.java

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class RedisVectorSetsEmbeddingStoreIT implements AutoCloseable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extend it with EmbeddingStoreIT or EmbeddingStoreWithFilteringIT

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be simplified with:

var joined = i
                    .stream()
                    .map(e -> {
                        if (e == null) {
                            return null;
                        } else if (e instanceof String s) {
                            return toString(s);
                        } else if (e instanceof  UUID s){
                            return toString(s);
                        } else {
                            return e.toString();
                        }
                    })
                    .filter(Objects::nonNull)
                    .collect(Collectors.joining(","));

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Makes sense to me!
Fixed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate filter.isPresent() check here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think throwing an exception when there are no matching elements seems a bit too harsh. Wouldn't it be better to just return an empty list?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should never throw an exception because if keep only Optional that actually has a value
BUT I agree with you that it's a bit too cruel so I changed it in:

  List<EmbeddingMatch<TextSegment>> matches = similarElements
          .entrySet()
          .stream()
          .map(this::mapToEmbeddingMatch)
          .flatMap(Optional::stream)

@Martin7-1 Martin7-1 added enhancement New feature or request P2 High priority P3 Medium priority theme: embedding store Issues/PRs related to embedding store labels Dec 6, 2025
@Jacopo47
Copy link
Author

Jacopo47 commented Dec 9, 2025

Hi, @Martin7-1
thank you for your review!
I'll work on it asap

@Jacopo47
Copy link
Author

Hi @Martin7-1 ,
I worked on some of your suggestions.
I still have to work on other fixes but I would wait for Redis' developments to be complete:

Because I would understand if these situation can be addressed by Redis it self or some "walk around" must be made by the embedding store.
(hopefully they will be addressed by redis)

@Martin7-1
Copy link
Collaborator

Great! No worry! Just ping me once you complete all tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request P2 High priority P3 Medium priority theme: embedding store Issues/PRs related to embedding store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Integrate with redis vector sets as EmbeddingStore

2 participants

Comments