You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Redis Enterprise中如何用JSON.GET查询包含Winter的season数据

Redis JSON 查询 season 包含"Winter"的条目

要查询warehouse:1中inventory数组里season包含"Winter"的元素,可以使用带过滤条件的JSON.GET命令:

JSON.GET warehouse:1 '$..inventory[?(@.season[] == "Winter")]'

命令解析

  • $..inventory:递归定位到文档中的inventory数组
  • [?(@.season[] == "Winter")]:过滤数组元素,@代表当前数组元素,@.season[]遍历该元素的season数组所有值,只要其中有一个等于"Winter",该元素就会被匹配返回

如果只需要返回特定字段(比如商品ID和描述),可以调整路径来指定返回结构:

JSON.GET warehouse:1 '$..inventory[?(@.season[] == "Winter")].{"id":@.id, "description":@.description}'

内容的提问来源于stack exchange,提问作者JShao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 03:35:06