简体   繁体   English

如何动态过滤 python 中 dynamoDB 中的 Map 项的嵌套列表

[英]How do I filter nested List of Map items from dynamoDB in python dynamically

How do I filter nested List of Map items from dynamoDB in python dynamically.如何动态过滤 python 中 dynamoDB 中的 Map 项的嵌套列表。

Below is the Json document.下面是 Json 文档。

"Items": [
{
  "shows": [
    "first",
    "second"
  ],
  "area": [
    {
      "areaCode": "ID1",
      "street": [
        "pvr1"
      ]
    }
  ],
 }
]

How do I filter records based on 'areaCode' = "ID1" I am getting records when I specify the index, but cannot hardcode the index value since the list might have more items.如何根据 'areaCode' = "ID1" 过滤记录我在指定索引时获取记录,但由于列表可能有更多项目,因此无法对索引值进行硬编码。 Is there a way to do it dynamically?有没有办法动态地做到这一点?

response = table.scan(
     FilterExpression = Attr("area[0].areaCode").contains("ID1")) 

DynamoDB does not have the ability to do wildcard searches on complex attributes like you are describing. DynamoDB 无法对您所描述的复杂属性进行通配符搜索。 If you want to search or filter by the area code attribute, you'll need to move it into an attribute or incorporate it in your primary key.如果要按区号属性进行搜索或过滤,则需要将其移动到属性中或将其合并到主键中。

The search functionality provided by DDB over complex attributes is limited. DDB 针对复杂属性提供的搜索功能是有限的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM