我阅读了下面的链接,该链接解释了如何通过表达式属性名使用占位符
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ExpressionPlaceholders.html#ExpressionAttributeValues
我的json文档存储如下:

{"user_json": {"profile.title":"abc"} }"

我的java代码如下
        Map<String, String> expressionAttributeNames = new HashMap<String, String>();
        expressionAttributeNames.put("#u1", "user_json.profile.title");

        String projectionExpression = "user_id, #u1";
        QuerySpec spec = new QuerySpec()
            .withProjectionExpression(projectionExpression)
            .withKeyConditionExpression("user_id = :v_id")
            .withNameMap(expressionAttributeNames)
            .withValueMap(new ValueMap()
                .withString(":v_id", userId))
            .withConsistentRead(true);

        ItemCollection<QueryOutcome> items = table.query(spec);
        Iterator<Item> iterator = items.iterator();
        String jsonPretty="";
        while (iterator.hasNext()) {
            jsonPretty = iterator.next().toJSON();
            System.out.println(jsonPretty);
        }

问题:无法检索包含点的文档路径。
有人能指出问题吗?感谢

最佳答案

试着这样做:

Map<String, String> expressionAttributeNames = new HashMap<String, String>();
expressionAttributeNames.put("#u1_1", "user_json");
expressionAttributeNames.put("#u1_2", "profile.title");

String projectionExpression = "user_id, #u1_1.#u1_2";

10-07 19:08