<small id='2UaWf'></small><noframes id='2UaWf'>

        <tfoot id='2UaWf'></tfoot>

        <i id='2UaWf'><tr id='2UaWf'><dt id='2UaWf'><q id='2UaWf'><span id='2UaWf'><b id='2UaWf'><form id='2UaWf'><ins id='2UaWf'></ins><ul id='2UaWf'></ul><sub id='2UaWf'></sub></form><legend id='2UaWf'></legend><bdo id='2UaWf'><pre id='2UaWf'><center id='2UaWf'></center></pre></bdo></b><th id='2UaWf'></th></span></q></dt></tr></i><div id='2UaWf'><tfoot id='2UaWf'></tfoot><dl id='2UaWf'><fieldset id='2UaWf'></fieldset></dl></div>

          <bdo id='2UaWf'></bdo><ul id='2UaWf'></ul>
        <legend id='2UaWf'><style id='2UaWf'><dir id='2UaWf'><q id='2UaWf'></q></dir></style></legend>
      1. DynamoDB:提供的关键元素与架构不匹配

        DynamoDB : The provided key element does not match the schema(DynamoDB:提供的关键元素与架构不匹配)

          <legend id='8YgwR'><style id='8YgwR'><dir id='8YgwR'><q id='8YgwR'></q></dir></style></legend>

            <tbody id='8YgwR'></tbody>
        1. <tfoot id='8YgwR'></tfoot>

            • <bdo id='8YgwR'></bdo><ul id='8YgwR'></ul>
              • <i id='8YgwR'><tr id='8YgwR'><dt id='8YgwR'><q id='8YgwR'><span id='8YgwR'><b id='8YgwR'><form id='8YgwR'><ins id='8YgwR'></ins><ul id='8YgwR'></ul><sub id='8YgwR'></sub></form><legend id='8YgwR'></legend><bdo id='8YgwR'><pre id='8YgwR'><center id='8YgwR'></center></pre></bdo></b><th id='8YgwR'></th></span></q></dt></tr></i><div id='8YgwR'><tfoot id='8YgwR'></tfoot><dl id='8YgwR'><fieldset id='8YgwR'></fieldset></dl></div>

                <small id='8YgwR'></small><noframes id='8YgwR'>

                  本文介绍了DynamoDB:提供的关键元素与架构不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法根据不是哈希键的字段来获取项目?

                  Is there a way to get an item depending on a field that is not the hashkey?

                  例子

                  我的表用户:id (HashKey)、姓名、电子邮件

                  我想检索电子邮件为test@mail.com"的用户

                  And I want to retrieve the user having email as 'test@mail.com'

                  如何做到这一点?

                  我用 boto 试试这个:

                  I try this with boto:

                  user = users.get_item(email='john.doe@gmail.com')
                  

                  我收到以下错误:

                  'The provided key element does not match the schema'
                  

                  推荐答案

                  要查询不是哈希键的字段,您需要使用全局二级索引 (GSI).看看 这篇 AWS 帖子 有关 GSI 的更多详细信息.

                  To query on fields which are not the hash key you need to use a Global Secondary Index (GSI). Take a look at this AWS Post for more details on GSI's.

                  2015 年 2 月更新:现在可以将 GSI 添加到现有表中.请参阅 亚马逊文档了解更多细节.

                  UPDATE Feb 2015: It is now possible to add a GSI to an existing table. See the Amazon Docs for more details.

                  可悲的是 您无法添加一个 GSI 到现有的 DynamoDB 表,因此如果您确实需要查询,则需要创建一个新表并移植您的数据.

                  Sadly you cannot add a GSI to an existing DynamoDB table so you'll need to create a new table and port your data if this is something you really need to query on.

                  来自 DynamoDB 常见问题解答:

                  问:如何为 DynamoDB 表创建全局二级索引?

                  必须在创建表时指定与表关联的所有 GSI时间.此时不能在表后添加GSI已经被创造了.有关创建表及其的详细步骤索引,请参阅此处.您最多可以创建 5 个全局二级每个表的索引.

                  All GSIs associated with a table must be specified at table creation time. At this time, it is not possible to add a GSI after the table has been created. For detailed steps on creating a Table and its indexes, see here. You can create a maximum of 5 global secondary indexes per table.

                  如果您不想移植您的数据,您可以考虑创建第二个 DynamoDB 表,其中电子邮件作为哈希键和父记录的哈希值用作对主数据表的查找,但当您可以想象这并不是一个最佳的解决方案,而且它也带来了与主表保持同步的问题.

                  这篇关于DynamoDB:提供的关键元素与架构不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)
                    <tfoot id='Skktw'></tfoot>
                  • <i id='Skktw'><tr id='Skktw'><dt id='Skktw'><q id='Skktw'><span id='Skktw'><b id='Skktw'><form id='Skktw'><ins id='Skktw'></ins><ul id='Skktw'></ul><sub id='Skktw'></sub></form><legend id='Skktw'></legend><bdo id='Skktw'><pre id='Skktw'><center id='Skktw'></center></pre></bdo></b><th id='Skktw'></th></span></q></dt></tr></i><div id='Skktw'><tfoot id='Skktw'></tfoot><dl id='Skktw'><fieldset id='Skktw'></fieldset></dl></div>

                        <legend id='Skktw'><style id='Skktw'><dir id='Skktw'><q id='Skktw'></q></dir></style></legend>

                        <small id='Skktw'></small><noframes id='Skktw'>

                            <tbody id='Skktw'></tbody>
                          • <bdo id='Skktw'></bdo><ul id='Skktw'></ul>