Nested filtering using CEL.

74 views
Skip to first unread message

Mohit Nagpal

unread,
Sep 13, 2023, 7:05:55 PM9/13/23
to CEL Go Discussion Forum
Have nested json. Looking for way to filter nested json. 
Json data and expression present in playground playground link

Objective is to find any book with seller city is "city_x"

Can do top level filter but did not see any option for nested filtering.
Top level filter works .
payload.filter(b, payload[b].isbn == "123-456-222")

Tristan Swadell

unread,
Sep 18, 2023, 4:24:59 PM9/18/23
to Mohit Nagpal, CEL Go Discussion Forum
Hi Mohit,

It sounds like you want a complex predicate:

payload.filter(b, payload[b].isbn == "123-456-222" && payload[b].city in ["city_x", "city_y"])

You could also express this as follows:

payload.filter(b, payload[b].isbn == "123-456-222" && payload[b].cities.exists(c, c== "city_x"))


-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cel-go-discuss/701b48bd-2b38-4a29-bed6-c80ff19625acn%40googlegroups.com.

Mohit Nagpal

unread,
Sep 18, 2023, 4:37:59 PM9/18/23
to Tristan Swadell, CEL Go Discussion Forum
under payload[b] there are sellerid1, selleride2 keys and city key is below that level.
Reply all
Reply to author
Forward
0 new messages