如何在DynamoDB(Python)中使用FilterExpression而不是嵌套属性?

时间:2017-07-17 13:59:01

标签: python amazon-web-services amazon-dynamodb boto boto3

这是我的json模型:

item=item={"Company":"ABCD",
               "Industry":"Invest.Services",
               "Sector":"Financial",
               "Financial_Results":
                             [{"Date":"2007-03-31","Frequency":"Annual","REV1":"20","REV3":"33"},
                              {"Date":"2008-03-31","Frequency":"Annual","REV1":"20","REV3":"34.43"},
                              {"Date":"2012-03-31","Frequency":"Annual","REV1":"30","REV3":Decimal("230")},
                              {"Date":"2013-03-31","Frequency":"Quarterly","REV1":Decimal("30"),"REV3":"3.32"},
                              {"Date":"2013-06-31","Frequency":"Quarterly","REV1":Decimal("20"),"REV3":"-0.343"},
                              {"Date":"2013-09-31","Frequency":"Quarterly","REV1":"20.50","REV3":"-0.543"}]
             }
    table.put_item(Item=item)

item=item={"Company":"EFGH",
               "Industry":"Mining",
               "Sector":"Metals",
               "Financial_Results":
                             [{"Date":"2007-03-31","Frequency":"Annual","REV1":"20","REV3":"33"},
                              {"Date":"2008-03-31","Frequency":"Annual","REV1":"20","REV3":"34.43"},
                              {"Date":"2012-03-31","Frequency":"Annual","REV1":"30","REV3":Decimal("230")},
                              {"Date":"2013-03-31","Frequency":"Quarterly","REV1":Decimal("30"),"REV3":"3.32"},
                              {"Date":"2013-06-31","Frequency":"Quarterly","REV1":Decimal("20"),"REV3":"-0.343"},
                              {"Date":"2014-03-31","Frequency":"Annual","REV1":"20.50","REV3":"-0.543"}]
             }
    table.put_item(Item=item)

公司 - 分区键(哈希键)。

无范围键(排序键)。

我的要求是:

  • 如何过滤'日期'属性相当于或超过' 2013-03-31'和' REV1'仅具有少于零项的属性。

注意: 我已经提到了以下链接 http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Attributes.html#DocumentPaths

我还是得不到任何结论。请帮助我。提前致谢

1 个答案:

答案 0 :(得分:0)

Atlast在R& D整整一天后找到了答案。 根据AWS DynamoDB文档和其他严肃的研究,我得出结论,我的json模型准备(顶部)目前不受支持。根据我的要求,我需要压缩我的数据而不是文档基础。感谢所有贡献者。