gpt4 book ai didi

amazon-web-services - 使用比较运算符的 DynamoDB 查询

转载 作者:行者123 更新时间:2023-12-03 15:15:13 25 4
gpt4 key购买 nike

亚马逊 AWS DynamoDB 问题。

是否有任何使用 RangeKeyCondition 和 ComparisonOperators 的示例,例如 CONTAINS、IN、BETWEEN。我正在尝试基于复合 RangeKey(连接和分隔)检索数据。例如书籍表的日期+作者+关键字。假设在这种情况下 HashValue 是“书”(它可以是书、DVD、视频、链接等)。我想选择所有包含关键字“magic”的书籍或作者“John Doe”的所有书籍。示例记录/项目如下所示:

哈希--------范围----------------------------- ----------------------- 属性 1 ... 属性 x

书------2012-1-20~john doe~adventure~magic~travel----description ...一些东西

在尝试使用条件运算符 IN 或 CONTAINS 时,我收到以下错误:
对象(CFSimpleXML)20
公共(public)'__type' => 字符串'com.amazon.coral.validate#ValidationException'(长度=45)
public 'message' => string '尝试的条件约束不是可索引操作'

找不到使用这些比较运算符的任何示例。任何帮助将不胜感激。

谢谢。

最佳答案

了解两个搜索 API 之间的区别很重要 Query and Scan in Amazon DynamoDB :

  • 询问

    A query operation searches only primary key attribute values and supports a subset of comparison operators on key attribute values to refine the search process. A query returns all of the item data for the matching primary keys (all of each item's attributes) up to 1MB of data per query operation. [...]

    [..] For information about each comparison operator available for query operations, see the API entry for Query.

    [emphasis mine]

  • 扫描

    A scan operation scans the entire table. You can specify filters to apply to the results to refine the values returned to you, after the complete scan. Amazon DynamoDB puts a 1MB limit on the scan (the limit applies before the results are filtered). [...]

    [...] For information about each comparison operator available for scan operations, see the API entry for Scan.


  • 现在,查询 API 的 RangeKeyCondition:ComparisonOperator 支持的子集不包括 CONTAINSIN ,虽然它们都在 Scan API 中可用;只有比较运算符 BETWEEN在两个 API 中都可用。

    这种限制很可能源于性能考虑,即支持 CONTAINS可能会破坏可预测的性能/吞吐量的 DynamoDB 目标。

    与 NoSQL 解决方案一样,您需要通过相应地定制应用程序设计来解决这些限制,即解决您的用例和您所针对的特定 NoSQL 架构。

    祝你好运!

    关于amazon-web-services - 使用比较运算符的 DynamoDB 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8966080/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com