Hello,
I am using scanAll
to filter records with a scan policy that contains a filter expression.
My data looks like the following:
{
"PK":"somePrimaryKey",
"someBinName":{
"key1":{
"fields":{
"a":true,
...
}
},
"key2":{
"fields":{
"a":false,
...
}
},
...
}
I am currently using the following expression:
Exp.build(
Exp.eq(
MapExp.getByKey(MapReturnType.VALUE, Exp.Type.BOOL, Exp.val("a"), Exp.mapBin("someBinName"), CTX.mapKey(Value.WILDCARD), CTX.mapKey(Value.get("fields"))), Exp.val(true)),
)
)
What I am trying to do is, find all records that contain a key within the bin someBinName
that contains a key by the name of fields
, which within it contains a key by the name of a
with the value true
. So it’s basically sort of an OR expression, if I see a nested key a
with the value true
within ANY of the top level keys, I want to retrieve this record. I am using Value.WILDCARD
because the top level keys (key1, key2, etc) are dynamic.
Assuming I have had the following structure for my data:
{
"PK":"somePrimaryKey",
"someBinName":{
"key1":{
"fields":{
"a":true,
...
}
}
}
The query will work just fine, and return all records that contain the keys and true value as described above, however if an additional key is added to the bin like so:
{
"PK":"somePrimaryKey",
"someBinName":{
"key1":{
"fields":{
"a":true,
...
}
},
"key2":{
"fields":{
"a":false,
...
}
}
}
Then the query may not pick up this record, even though it does contain some key, which within it there’s a map with the key fields
which within it there is a key by the name of a
with the value true
, in this case it would be key1
. What I noticed is that when using Value.WILDCARD
it picks a single key within the bin and executes the expression on that key alone, and the key that will be picked is the key which was most recently added/updated. So if I added key2
AFTER I added key1
the expression will not return my desired records, however if I added key1
AFTER key2
then it will return the records.
I guess I am probably using it wrong, even though it made sense to me that Value.WILDCARD
will descent down all possible keys in the bin.
I had a good look at the documentation and the tutorial notebooks but I didn’t find anything that’s similar to my use case. Would appreciate if anyone can give me some insight on how I could build the expression such that it will return records as I described above, thank you.