在gsi上不比较java排序键

px9o7tmv  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(153)

我有一个ddb表,在那里我创建了一个gsi。属性如下。我有分区键作为createdby,排序键作为status。

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@DynamoDBTable(tableName = "SomeTable")
public class SchoolInfoObject {

# Some attributes and GSI on them also exists

@DynamoDBIndexRangeKey(globalSecondaryIndexName = "created_by-status-index",
            attributeName = "status")
@DynamoDBAttribute(attributeName = "status")
@DynamoDBTypeConvertedEnum
private SomeEnum status;

@DynamoDBIndexHashKey(globalSecondaryIndexName = "created_by-status-index",
            attributeName = "created_by")
@DynamoDBAttribute(attributeName = "created_by")
private String createdBy;
}

我使用下面的表达式来获取记录。

SchoolObject hashKObject = new SomeObject();
        hashKObject.setCreatedBy(ID);
        hashKObject.setStatus(status);
        DynamoDBQueryExpression<SchoolInfoObject> queryExpression = new DynamoDBQueryExpression<SchoolInfoObject>()
                .withIndexName("created_by-status-index")
                .withHashKeyValues(hashKObject)
                .withConsistentRead(false);
final List<SomeObject> list = dao.query(SomeObject.class, queryExpression);

其中dao.query调用ddbMap器查询。我面临的问题是,我得到的所有记录都与分区键匹配(排序键没有被比较)。
有人能告诉我我犯了什么错误吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题