Replacement for PredExp on a list bin

92 views Asked by At

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 it's not working as expected.

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

I used expression to replicate the issue, but I think I might have to use a filter inside of statement. I already have a filter getting passed in statement for the query. Can two filters be merged into one?

1

There are 1 answers

0
pgupta On

Looks like you asked the same question here: https://discuss.aerospike.com/t/replacement-for-predexp-on-a-list-bin-of-strings/10657/2 - I validated your Expression construct. (I had used listValueExp there, now referred below.) You have added more color to your question here. So let me continue: For a read query: query(QueryPolicy qPolicy, Statement stmt) you will specify the Secondary Index filter (if you are using one) in the Statement object and the filter expression to be applied after records that match the SI using the QueryPolicy object. e.g.

stmt.setFilter(Filter.range("age",20,60)); -- for SI

qPolicy.filterExp = listValueExp; -- for expression based subsequent filtering. Hope this clarifies.