Replacement for PredExp on a List Bin of Strings

Hi Community,

I have a bin of type List. I want to query and get the records for which this bin has a value equal to variable ‘val’, lets say. Using PredExp this can be done using -

predExps = Arrays.asList(
 			PredExp.stringVar("v"),
 			PredExp.stringValue(String.valueOf(val)),
 			PredExp.stringEqual(),
 			PredExp.listBin(fieldName),
 			PredExp.listIterateOr("v"));

After PredExp has been deprecated 6.0.0 onwards, how can the same behaviour be replicated? I am using Expressions for the same, but its not working as expected.

exp = Exp.build(
                    ListExp.getByValue(
                            ListReturnType.VALUE,
                            Exp.val(String.valueOf(val)),
                            Exp.listBin(fieldName)
                    )
            );

Please help out here

Your expression seems correct. Not sure how you are using it later. Here is a replication of your code:

Key key = new Key("test", "testset", "key2");
WritePolicy wPolicy = new WritePolicy();
String fieldName = "data";

List<Value> values = new ArrayList<Value>();

values.add(Value.get("Sam"));
values.add(Value.get("Pat"));
values.add(Value.get("Bill"));

Bin listData = new Bin(fieldName, Value.get(values));
client.put(wPolicy, key, listData);
System.out.println("Record: "+ client.get(null, key)); //check record got inserted

String val = "Bill";

Expression listValueExp = Exp.build(
                                      ListExp.getByValue(
                                          ListReturnType.VALUE,
                                          Exp.val(String.valueOf(val)), 
                                          Exp.listBin(fieldName)
                                      )
                                   );
Record record = client.operate( wPolicy, key,   
          ExpOperation.read("matchedValue", listValueExp, ExpReadFlags.DEFAULT) 
         );
System.out.println("Match found? : " + record.getValue("matchedValue"));

and the output when I set val = “Bill”:

Record: (gen:18),(exp:438814020),(bins:(data:[Sam, Pat, Bill]))
Match found? : [Bill]

vs when I set val = “Billy

Record: (gen:19),(exp:438814051),(bins:(data:[Sam, Pat, Bill]))
Match found? : []

I see you have also posted at: java - Replacement for PredExp on a list bin - Stack Overflow … response continued there.