1
votes

In DynamoDB my query is not working with ComparisonOperator other than EQ in PHP. I am using Global Secondary Indexes:

$response = $client->query(array(
    "TableName" => $tableName,
    "IndexName" => "topRating", // GSI index name
    "KeyConditions" => array(
        "rating" => array(
            "ComparisonOperator" => "NE", // Only 'EQ' works
            "AttributeValueList" => array(
                array(Type::STRING => "1186") // Sample value
            )
        )
    ),
    "ScanIndexForward" => true,
    "limit" => 5
));

When creating the table I used rating as hash key for creating topRating GSI

The response is as follows:

Fatal error: Uncaught Aws\DynamoDb\Exception\ValidationException: AWS Error Code: ValidationException, Status Code: 400, AWS Request ID: XXXXXYYYYYZZZZ, AWS Error Type: client, AWS Error Message: Attempted conditional constraint is not an indexable operation, User-Agent: aws-sdk-php2/2.7.0 Guzzle/3.9.2 curl/7.19.7 PHP/5.4.30 thrown in ....

1
What is the response?Bas Peeters
Please edit your question and paste that output between code tagsBas Peeters
Also maybe remove or feign sensitive/revealing information like personal folder names and request id'sBas Peeters
@ManeatingKoala can you help me?Joy Das

1 Answers

0
votes

According to the AWS docs (link), it seems that the query operation doesn't support the NE operator:

Scan operations support all available comparison operators. Query operations support a subset of the available comparison operators: EQ, LE, LT, GE, GT, BETWEEN, and BEGINS_WITH.

The scan operation does support it.