Skip to content

GH-5670: Fix type field indexing in RedisChatMemoryRepository#5731

Open
sachinnn99 wants to merge 1 commit intospring-projects:mainfrom
sachinnn99:GH-5670
Open

GH-5670: Fix type field indexing in RedisChatMemoryRepository#5731
sachinnn99 wants to merge 1 commit intospring-projects:mainfrom
sachinnn99:GH-5670

Conversation

@sachinnn99
Copy link
Copy Markdown

Summary

RedisChatMemoryRepository defines the $.type field as a TextField in the RediSearch index schema. TextField performs full-text tokenization (lowercasing, stemming), which breaks exact-match filtering on message type enum values like USER, ASSISTANT, SYSTEM, and TOOL. This causes get() to only return USER type messages.

Fix: Change $.type from TextField to TagField for exact-match semantics, and update findByType() to use Values.tags() (tag query syntax) instead of Values.value() (text query syntax). Also update raw query strings in tests to use tag field syntax (@type:{VALUE}).

Changes

  • RedisChatMemoryRepository.java: TextField("$.type")TagField("$.type") in index schema; Values.value()Values.tags() in findByType()
  • RedisChatMemoryAdvancedQueryIT.java: Update raw query strings from @type:VALUE to @type:{VALUE}

Note for existing deployments

Since initializeSchema() skips index creation when the index already exists, existing deployments need to drop and recreate the index for this fix to take effect:

FT.DROPINDEX <index-name>

Then restart the application to create the index with the corrected schema.

Closes #5670

…ository

Use TagField instead of TextField for the $.type JSON path in the
RediSearch index schema. TextField performs full-text tokenization
which breaks exact-match filtering on message type enum values,
causing get() to only return USER type messages.

Also update findByType() query to use Values.tags() (tag query syntax)
instead of Values.value() (text query syntax), and fix raw query
strings in tests to use tag field syntax (@type:{VALUE}).

Closes spring-projects#5670

Signed-off-by: Sachin <52783123+sachinnn99@users.noreply.github.com>
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.

The get method of RedisChatMemoryRepository only returns data of type USER

1 participant