简体   繁体   中英

How can i use FilterExpression over Nested Attributes in DynamoDB (Python)?

Here is my json model:

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)

Company - Partition key (Hash Key).

No Range Key(Sort key).

My Requirements are:

  • How can i filter the 'Date' attribute equivalent or more than '2013-03-31' and 'REV1' attribute with less than zero items only.

Note: I have referred the following link http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Attributes.html#DocumentPaths

I still dont get any conclusions.Kindly help me. Thanks in advance

Atlast i found an answer after made R&D for a whole day. As per AWS DynamoDB documentation and other serious researches, I conclude that my json model preparation ( At the Top ) is currently not supported .As per my requirement, I need to flatten my data instead of document basis.Thanks for every contributors though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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