No hash key condition is applicable to the specified index

4.3k views Asked by At

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);
1

There are 1 answers

0
Alexander Patrikalakis On

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.