Requesting a parameter that is not an index on DynamoDb

TableName: people

id | name | age | a place

id_1 | A | 23 | New Zealand

id_2 | B | 12 | India

id_3 | C | 26 | Singapore

id_4 | D | 30 | Turkey

: id → hash and age → range

Question 1

I'm trying to fulfill the request: "Choose * from people, age> 25" I can get it to work with queries such as "Choose age from people where id = id_1 and age> 25", which is not what I need, just you need to select all the values.

And if I don't need age to be a range index, how can I change the query parameters to just return a list of records that meet the criteria: age> 25?

Question 2

AWS , 23 24-41. : Query Error: ValidationException: KeyConditions KeyConditionExpression.                : 400, : []

KeyConditions/KeyConditionsExpressions? , , ?

  func queryDynamo() {
        log.Println("Enter queryDynamo")

        svc := dynamodb.New(nil)

        params := &dynamodb.QueryInput{
            TableName: aws.String("people"), // Required
            Limit:     aws.Long(3),
            // IndexName: aws.String("localSecondaryIndex"),
            ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
                ":v_age": { // Required
                    N: aws.String("25"),
                },
                ":v_ID": {
                    S: aws.String("NULL"),
                },
            },
            FilterExpression: aws.String("age >= :v_age"),

            // KeyConditionExpression: aws.String("id = :v_ID and age >= :v_age"),
            KeyConditions: map[string]*dynamodb.Condition{
                "age": { // Required
                    ComparisonOperator: aws.String("GT"), // Required
                    AttributeValueList: []*dynamodb.AttributeValue{
                        { // Required
                            N: aws.String("25"),
                        },
                        // More values...
                    },
                },
                "id": { // Required
                    ComparisonOperator: aws.String("EQ"), // Required
                    // AttributeValueList: []*dynamodb.AttributeValue{
                    //  S: aws.String("NOT_NULL"),
                    // },
                },
                // More values...
            },
            Select:           aws.String("ALL_ATTRIBUTES"),
            ScanIndexForward: aws.Boolean(true),
        }

//Get the response and print it out.
        resp, err := svc.Query(params) 

        if err != nil {
            log.Println("Query Error: ", err.Error())
        }

        // Pretty-print the response data.
        log.Println(awsutil.StringValue(resp))
    }
+4
1

DynamoDB - NoSQL, .

DynamoDB , ( ) ( IOPS).

- , . -.

: ( 100) , , . - cron backend, , , , IOPS .

+4

Source: https://habr.com/ru/post/1599541/


All Articles