com.amazonaws.AmazonServiceException: Query key condition not supported
<p>I am fetching data from AWS DynamoDB Table. With the below code, I can fetch single item from table with this code.</p>

<pre><code>    Condition hashKeyCondition = new Condition()
            .withComparisonOperator(ComparisonOperator.GE.toString())
            .withAttributeValueList(new AttributeValue().withN("1"));

    Map&lt;String, Condition&gt; keyConditions = new HashMap&lt;String, Condition&gt;();
    keyConditions.put("ID", hashKeyCondition);

    Map&lt;String, AttributeValue&gt; lastEvaluatedKey = null;

    do
    {
        QueryRequest queryRequest = new QueryRequest()
                .withTableName("TABLE_NAME")
                .withKeyConditions(keyConditions)
                .withExclusiveStartKey(lastEvaluatedKey);

        QueryResult queryResult = dynamoDBClient.query(queryRequest);

        for (Map&lt;String, AttributeValue&gt; item : queryResult.getItems())
        {
            String value = item.get("column_name").getS();
            Log.i("MainActivity", value);
        }

        lastEvaluatedKey = queryResult.getLastEvaluatedKey();

    } while (lastEvaluatedKey != null);
</code></pre>

<p><br>
But I am trying to fetch all the items that are greater than ID = "1". So I changed the <code>ComparisonOperator.GE</code> to <code>ComparisonOperator.GT</code>. Below is the following code.<br></p>

<pre><code>Condition hashKeyCondition = new Condition()
    .withComparisonOperator(ComparisonOperator.GT.toString())
    .withAttributeValueList(new AttributeValue().withN("1"));

Map&lt;String, Condition&gt; keyConditions = new HashMap&lt;String, Condition&gt;();
keyConditions.put("ID", hashKeyCondition);

Map&lt;String, AttributeValue&gt; lastEvaluatedKey = null;

do
{
    QueryRequest queryRequest = new QueryRequest()
            .withTableName("TABLE_NAME")
            .withKeyConditions(keyConditions)
            .withConsistentRead(true)
            .withExclusiveStartKey(lastEvaluatedKey);

    QueryResult queryResult = dynamoDBClient.query(queryRequest);

    for (Map&lt;String, AttributeValue&gt; item : queryResult.getItems())
    {
        String value = item.get("column_name").getS();
        Log.i("MainActivity", value);
    }

    lastEvaluatedKey = queryResult.getLastEvaluatedKey();

} while (lastEvaluatedKey != null);
</code></pre>

<p><br><strong>But I am getting AmazonServiceException</strong><br>
<code>com.amazonaws.AmazonServiceException: Query key condition not supported (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: XXXXXXXXXXXXXXXXXXXXXXXXXXX</code>. </p>

<p>Please Help.</p>