Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon dynamodb Dynamodb是否可以查询列中的所有值_Amazon Dynamodb - Fatal编程技术网

Amazon dynamodb Dynamodb是否可以查询列中的所有值

Amazon dynamodb Dynamodb是否可以查询列中的所有值,amazon-dynamodb,Amazon Dynamodb,我正试图找出一个查询列中所有值的最佳方法。我应该将其设置为GSI吗?它当前是。是否可以通过查询或我需要进行扫描 感谢您的帮助如果不按键筛选,您必须进行扫描。下面是扫描索引并获取所有值的示例代码 List<String> categoryList = new ArrayList<>(); DynamoDB dynamoDB = new DynamoDB(dynamoDBClient); Table table = dynamoDB.getTable(

我正试图找出一个查询列中所有值的最佳方法。我应该将其设置为GSI吗?它当前是。是否可以通过查询或我需要进行扫描


感谢您的帮助

如果不按键筛选,您必须进行扫描。下面是扫描索引并获取所有值的示例代码

    List<String> categoryList = new ArrayList<>();
    DynamoDB dynamoDB = new DynamoDB(dynamoDBClient);
    Table table = dynamoDB.getTable("Music");
    Index index = table.getIndex("Secondary Index Name");

    ItemCollection<ScanOutcome> items = null;   
    ScanSpec scanSpec = new ScanSpec().withSelect(Select.SPECIFIC_ATTRIBUTES).withAttributesToGet("Category");

    items = index.scan(scanSpec);
    Iterator<Item> pageIterator = items.iterator();
    while (pageIterator.hasNext() ) {

        categoryList.add(pageIterator.next().getString("Category"));
    }

如果不按键过滤,则必须进行扫描。下面是扫描索引并获取所有值的示例代码

    List<String> categoryList = new ArrayList<>();
    DynamoDB dynamoDB = new DynamoDB(dynamoDBClient);
    Table table = dynamoDB.getTable("Music");
    Index index = table.getIndex("Secondary Index Name");

    ItemCollection<ScanOutcome> items = null;   
    ScanSpec scanSpec = new ScanSpec().withSelect(Select.SPECIFIC_ATTRIBUTES).withAttributesToGet("Category");

    items = index.scan(scanSpec);
    Iterator<Item> pageIterator = items.iterator();
    while (pageIterator.hasNext() ) {

        categoryList.add(pageIterator.next().getString("Category"));
    }

DynamoDB不是一个分析数据库。如果您需要一次,可以使用scan,但如果您需要,可以经常使用其他解决方案从DynamoDB更新流中进行红移,或者在ElastiCache中的Redis中维护更新流中的值集。DynamoDB不是分析数据库。如果需要一次,可以使用scan,但如果需要,可以经常使用其他解决方案从DynamoDB更新流中进行红移,或者在ElastiCache中的Redis中维护更新流中的值集。