AnAndroid
AnAndroid

Reputation: 567

No hash key condition is applicable to the specified index

I am trying to query from dynamoDB using a query expression with index name and defined secondryGlobalIndex in object.

But response is

Illegal query expression: No hash key condition is applicable to the specified index

code that I am using

DynamoDBQueryExpression queryExpression = new DynamoDBQueryExpression()
            .withHashKeyValues(valueObject)
            .withIndexName("postID-commentTime-index")
            .withConsistentRead(false);



    try {
        PaginatedQueryList<ValueObject> result = 
(PaginatedQueryList) mapper.query(valueObjectClass, queryExpression);

Upvotes: 1

Views: 4529

Answers (1)

Alexander Patrikalakis
Alexander Patrikalakis

Reputation: 5195

Key conditions when querying an index pertain to the schema of the index and not of the base table. Make sure the key condition you are passing into the query is for the index and not the base table.

Upvotes: 1

Related Questions