- Newest
- Most votes
- Most comments
This appears to be a limitation in ElastiCache's implementation of JSONPath filtering. While ElastiCache for Redis OSS and Valkey does support JSONPath and is compatible with version 2 of the JSON module, there are some differences in how it handles complex path expressions.
Based on the documentation, ElastiCache can directly filter array objects, but the examples shown in the documentation are simpler than what you're trying to achieve. The documentation shows examples like $[?(@<4)] or $.my_key[?(@<4)] where the filter condition is a direct comparison without nested field references.
The error messages you're receiving ("Invalid JSON path" or "Array index is not a number") suggest that ElastiCache's JSONPath implementation doesn't support the nested field dereferencing within filter predicates that you're attempting to use.
As a workaround, you might need to:
- Retrieve the entire transactions array first and then filter client-side
- Use multiple JSON commands to navigate the structure step by step
- Consider restructuring your data to flatten the nested attributes you need to filter on
The documentation doesn't explicitly mention support for nested field references in filter predicates, which suggests this might be a limitation rather than a bug. The JSON support in ElastiCache requires Valkey 7.2+ or Redis OSS 6.2.6+, but there's no indication that higher versions would support this specific functionality.
Sources
Getting started with JSON for Valkey and Redis OSS - Amazon ElastiCache
JSON data type overview - Amazon ElastiCache
This is a known limitation of Amazon’s managed JSON implementation, not a bug in your queries. In Amazon ElastiCache (both Redis OSS and Valkey engines), the JSON module is not feature-complete with upstream RedisJSON v2, even though AWS documentation describes “JSONPath support.” Specifically, ElastiCache’s JSONPath parser only supports single-level field dereferencing inside filter predicates. Any predicate that requires nested object traversal (for example @.installment_details.eligibility) fails during parse time with SYNTAXERR Invalid JSON path. This is why all syntactic variations you tried fail: the limitation is structural, not syntactic. Upstream RedisJSON (and Valkey JSON) support nested dereference in predicates because they use a newer JSONPath evaluator; ElastiCache currently uses a restricted fork optimized for safety and performance, and nested predicates are intentionally unsupported. There is no ElastiCache engine version today (as of Redis OSS 7.x / Valkey 7.x) that enables this capability.
Workarounds:
- Denormalize the nested field (e.g., copy
installment_details.eligibilityto a top-level field). - Filter client-side after fetching
$.transactions[*]. - Use secondary indexing patterns (e.g., maintain sets keyed by eligibility).
- If full JSONPath compliance is required, run self-managed Redis/Valkey (EC2, EKS, or containers).
answered 9 months ago
Relevant content
asked a year ago
