Skip to content

fix: GH-3690, enhance RedisVectorStore with RedisVectorStoreBuilderCustomizer #3809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lanpf
Copy link

@lanpf lanpf commented Jul 13, 2025

Description

This PR introduces a generic extension point for customizing VectorStore.Builder via VectorStoreBuilderCustomizer and fixes retrieval failures in RedisVectorStore.

Background

Previously, when using VectorStoreChatMemoryAdvisor with RedisVectorStore and initialize-schema=true, metadata fields like conversationId (used in filterExpression) weren't registered in the Redis schema. This occurred because RedisVectorStoreProperties didn't support setting metadataFields during auto-configuration, causing retrieval failures during similarity search.

Related issue: #3690

Changes

  1. Introduces base VectorStoreBuilderCustomizer<T extends VectorStore.Builder<T>> interface
    • Provides extension point for all VectorStore implementations
  2. Adds Redis-specific RedisVectorStoreBuilderCustomizer
    • Extends VectorStoreBuilderCustomizer<RedisVectorStore.Builder>
  3. Modifies RedisVectorStoreAutoConfiguration
    • Uses RedisVectorStore.Builder as dependency
    • Applies ordered customizers during configuration
  4. Includes comprehensive unit tests (special thanks to @Acacian)

New Customization Pattern

Developers can now customize metadata fields non-invasively:

@Bean
public RedisVectorStoreBuilderCustomizer metadataCustomizer() {
    return builder -> builder.metadataFields(
        List.of(RedisVectorStore.MetadataField.tag("conversationId"))
    );
}

Impact

  • Enables schema initialization and metadata filtering to work together
  • Maintains initialize-schema=true functionality
  • Eliminates need for manual RedisVectorStore wiring
  • Follows Spring's open/closed principle for extension

Special Thanks

🙌 To @Acacian for test contributions and valuable feedback.

Closes: #3690

Looking forward to your review!

@Acacian
Copy link

Acacian commented Jul 14, 2025

Thank you for keeping the words you shared earlier. I’ll also keep the words I said before. I appreciate your thoughtfulness.
I hope your contribution will be included in the next release.
Could you please add Closes #XXXX in the PR description to indicate that this issue was resolved by your contribution?
This helps automatically close the issue when the PR is merged and properly credit your work. Thank you!

…rStoreBuilderCustomizer, add generic VectorStore.Builder customizer interface and Redis-specific customizer interface

Signed-off-by: lanpf <[email protected]>
@lanpf lanpf force-pushed the GH-3690-add-redis-vectorstorebuilder-customizer branch from 6d748cc to 1d8243f Compare July 14, 2025 16:43
@lanpf
Copy link
Author

lanpf commented Jul 14, 2025

Thank you for keeping the words you shared earlier. I’ll also keep the words I said before. I appreciate your thoughtfulness. I hope your contribution will be included in the next release. Could you please add Closes #XXXX in the PR description to indicate that this issue was resolved by your contribution? This helps automatically close the issue when the PR is merged and properly credit your work. Thank you!

Thanks for pointing that out! I've corrected the formatting - the issue reference Closes #3690 is now properly displayed in markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RedisVectorStore auto-configuration does not support metadataFields, causing chat memory retrieval failure
2 participants