Primary Key :: EmployeeIdValueEmployeeIdType
Secondary Index :: AlternateEmployeeId
1.we are fetching all the keys from the input and storing it in the KeystoFetch.
List<String> keysToFetch = new ArrayList<>();
for (Employee employee: body.getEployees()) {
keysToFetch.add(employee.getIdValue() + employee.getIdType());
}
2. Preparing the Key
Key[] keySize = new Key[keysToFetch.size()];
for (int i = 0; i < keySize.length; i++) {
keySize[i] = new Key(SchmeaName, TableName, keysToFetch.get(i));
}
3. we are using the batch to query the data.
Record[] records = aspClient.get(null, keySize);
List<String> alternateEmployeeIdList= new ArrayList<>();
for (Record record : records) {
if (record != null) {
String alternateEmployeeId= record.getString("AlternateEmployeeId");
if (alternateEmployeeId!= null) {
alternateEmployeeIdList.add(alternateEmployeeId);
}
}
}
4. Now I got all the alternateEmployeeIdList .With the help alternateEmployeeIdList i need to query the database to get the Primary key and other bins like (location, role, number).
Below are the solutions which i tried. Its not taking all the alternateEmployeeIdList in the filter. can someone suggest how to resolve this issue.
Statement statement = new Statement();
statement.setNamespace(schema);
statement.setSetName(tablename);
statement.setBinNames("location","role","number");
for(String alternateEmployeeId: alternateEmployeeIdList){
**statement.setFilter(Filter.contains("AlternateEmployeeId",IndexCollectionType.LIST,alternateEmployeeId));**
}
RecordSet recordSet = aspClient.query(new QueryPolicy(), statement);