Summary
The Valkey vector store defines the memory field as a TAG type in the index schema, but it should be TEXT to enable full-text search over memory content.
Current behavior:
# In DEFAULT_FIELDS and _build_index_schema
{"name": "memory", "type": "tag"}, # Using TAG instead of TEXT for Valkey compatibility
The FT.CREATE command uses:
Problem:
TAG fields are designed for exact-match filtering on categorical values (e.g., user IDs, labels). They tokenize only on comma separators and match whole tokens. This means:
- Users cannot do full-text search over stored memories (e.g., searching for memories containing "python" or "meeting notes")
- TAG fields with long text content waste memory on oversized inverted index entries since the entire string becomes one token
- The filter syntax
@memory:{value} only matches exact comma-separated values, not partial text
Proposed fix:
Change the memory field from TAG to TEXT in both DEFAULT_FIELDS and _build_index_schema:
# DEFAULT_FIELDS
{"name": "memory", "type": "text"},
# _build_index_schema cmd
"memory", "TEXT",
Valkey Search (valkey-search module) fully supports TEXT field types with stemming, tokenization, and full-text query syntax. The existing comment "Using TAG instead of TEXT for Valkey compatibility" appears to be outdated since TEXT has been supported since the initial valkey-search release.
This would enable hybrid search patterns combining vector similarity with text filters:
@memory:(meeting notes) =>[KNN 5 @embedding $vec_param AS vector_score]
Note: This is a schema change that requires re-indexing existing data. Consider adding a migration path or documenting that users should drop and recreate their index after upgrading.
Environment
- valkey.py:
mem0/vector_stores/valkey.py
- Affects:
DEFAULT_FIELDS, _build_index_schema()
Summary
The Valkey vector store defines the
memoryfield as aTAGtype in the index schema, but it should beTEXTto enable full-text search over memory content.Current behavior:
The
FT.CREATEcommand uses:Problem:
TAG fields are designed for exact-match filtering on categorical values (e.g., user IDs, labels). They tokenize only on comma separators and match whole tokens. This means:
@memory:{value}only matches exact comma-separated values, not partial textProposed fix:
Change the
memoryfield fromTAGtoTEXTin bothDEFAULT_FIELDSand_build_index_schema:Valkey Search (valkey-search module) fully supports
TEXTfield types with stemming, tokenization, and full-text query syntax. The existing comment "Using TAG instead of TEXT for Valkey compatibility" appears to be outdated since TEXT has been supported since the initial valkey-search release.This would enable hybrid search patterns combining vector similarity with text filters:
Note: This is a schema change that requires re-indexing existing data. Consider adding a migration path or documenting that users should drop and recreate their index after upgrading.
Environment
mem0/vector_stores/valkey.pyDEFAULT_FIELDS,_build_index_schema()