1

I am trying to query using an index but keep getting this error:

ValidationException: Query condition missed key schema element: trackID

Here is my .arc file

@tables
skytracks
  trackID *String
  _ttl TTL

@indexes
skytracks
  skyTrackType *String

Here is the relevant piece of the http get handler:

const skyTrackType = req.queryStringParameters.skytracktype
const data = await arc.tables()
const trackingData = await data.skytracks.query({
      KeyConditionExpression: `skyTrackType = :skyTrackType`,
      ExpressionAttributeValues: {
        ':skyTrackType': skyTrackType
      }
    })
Neil Hoff
  • 2,025
  • 4
  • 29
  • 53

1 Answers1

1

Architect automatically names the index attribute-index

This needs to be added to the query in the question: IndexName: 'skyTrackType-index'

const trackingData = await data.skytracks.query({
      KeyConditionExpression: `skyTrackType = :skyTrackType`,
      IndexName: 'skyTrackType-index',
      ExpressionAttributeValues: {
        ':skyTrackType': skyTrackType
      }
    })
Neil Hoff
  • 2,025
  • 4
  • 29
  • 53
  • 1
    This was a little funky to figure out, glad I found your answer. Looks like their helper functionality arc.tables().data.tblName._name() doesn't work correctly yet with indexes. https://arc.codes/reference/functions/tables/node#data.name – gbland777 Aug 30 '20 at 05:43