So i have a dynamo table for employee with the following fields
employeeid (primary index/hash key)
someotherid (GSI)
firstname (GSI)
lastname
email
dob
secretkey
address
phone
email (GSI)
I cannot create a gsi on any more fields besides what i have above.
what i need to do is search for employees with the same
firstname,
lastname,
dob
and secretkey,
if i dont have one then i need to insert a new employee if i do i need to perform an action.
is there a way in dynamodb using c# where i could search on those 4 fields?
i have a gsi on firstname, i do not want to use a scan which allows me to use filters, is there a way to query or filter using the firstname gsi i have without doing a scan on the table.
Any advice would be appreciated.
Thanks for reading.
update
this is what i tried in c#
var request = new QueryRequest()
{
TableName = "employee",
IndexName = "firstName-employeeId-index",
Select = Select.ALL_ATTRIBUTES,
ScanIndexForward = false
};
String keyConditionExpression;
Dictionary<string, AttributeValue> expressionAttributeValues = new Dictionary<string, AttributeValue>();
keyConditionExpression = "firstName = :firstName and lastName = :lastName ";
expressionAttributeValues.Add(":firstName", new AttributeValue { S = firstName });
expressionAttributeValues.Add(":lastName", new AttributeValue { S = lastName });
request.KeyConditionExpression = keyConditionExpression;
request.ExpressionAttributeValues = expressionAttributeValues;
var result = await Client.QueryAsync(request);
I get an error when i run the above as it looks for my hashkey.