My primary key is a field called "id"
I've added a secondary index to my table on the field "group_number"
I query via the secondary index like so:
// Query the secondary index
queryInput := &dynamodb.QueryInput{
TableName: aws.String(c.GetDynamoDBTableName()),
KeyConditions: map[string]*dynamodb.Condition{
"group_number": {
ComparisonOperator: aws.String("EQ"),
AttributeValueList: []*dynamodb.AttributeValue{
{
S: aws.String(c.GroupNumber),
},
},
},
},
}
However; I get the error "validationexception: query condition missed key schema element: id"
Does DynamoDB only allow the querying of primary keys? I was under the impression you use "GetItem" for primary key being that only one record can come back if you use a primary key. To search via secondary indexes you use "Query", and to search by non-index keys, you use "Scan".
Please let me know what I'm doing incorrectly here.