Java DynamoDB:使用LSI获取最后记录

Java DynamoDB:使用LSI获取最后记录,java,amazon-web-services,amazon-dynamodb,Java,Amazon Web Services,Amazon Dynamodb,我们有以下java代码用于获取表中的最后一条记录: Map<String, Condition> _keyCondn = new HashMap<String, Condition>(); _keyCondn.put(HASH_ID, new Condition() .withComparisonOperator(ComparisonOperator.EQ) .withAttributeVal

我们有以下java代码用于获取表中的最后一条记录:

Map<String, Condition> _keyCondn = new HashMap<String, Condition>();
_keyCondn.put(HASH_ID, new Condition()
                    .withComparisonOperator(ComparisonOperator.EQ)
                    .withAttributeValueList(new AttributeValue().withS(hashId)));

    QueryRequest qr = new QueryRequest();

    if (fltrField != null && fltrAttr != null)
    {
        _keyCondn.put(fltrField, new Condition()
                        .withComparisonOperator(ComparisonOperator.EQ)
                        .withAttributeValueList(fltrAttr));
        if (fltrIndex != null)
            qr.setIndexName(fltrIndex);
    }


    qr.withTableName(tableName)
        .withKeyConditions(_keyCondn)
        .withScanIndexForward(false);

    qr.withConsistentRead(true)
        .withLimit(1);
Map\u keyCondn=newhashmap();
_keyCondn.put(HASH_ID,新条件()
.带ComparisonOperator(ComparisonOperator.EQ)
.WithAttributeValue列表(新的AttributeValue().withS(hashId));
QueryRequest qr=新的QueryRequest();
if(fltrField!=null&&fltrAttr!=null)
{
_keyCondn.put(外场,新条件()
.带ComparisonOperator(ComparisonOperator.EQ)
.使用属性值列表(fltrAttr));
如果(fltrIndex!=null)
qr.setIndexName(fltrIndex);
}
qr.withTableName(tableName)
.withKeyConditions(_keyCondn)
.使用CANINDEXFORWARD(假);
qr.具有一致性读数(正确)
.有限制(1);
请求工作正常,直到我将if语句包含在LSI中。有没有办法让这一切顺利进行? 或者至少是一个更好的解决方案,然后“获取最后一条记录,向后扫描,直到获得所需的值”