Check if value of property exists in nested arrays of object

i have this data

[
{
“id”: “mapping:1686:2004:test”,
“bucket”: {
“mappings”: [
{
“destinations”: [
{
“dest_question”: “7480”
}
],
“src_format”: “123asd”,
“src_question”: “asD”,
“src_type”: “DATE”
},
{
“destinations”: [
{
“dest_answers”: [
“13”
],
“dest_question”: “4930”,
“src_answer”: “asd/asdasd”
}
],
“src_format”: “”,
“src_question”: “asd/asd”,
“src_type”: “ENUM_SINGLE”
}
],
}
}
]

i want to check if src_answer string already exists for specific src_question.
I am trying to do it something like this for example :

SELECT count(*) AS cnt FROM trials USE KEYS [‘mapping:1686:2004:test’] WHERE
ANY m IN IFMISSINGORNULL(mappings, ) SATISFIES LOWER(m.src_question) = ‘asd/asd’ AND
ANY dest IN IFMISSINGORNULL(m.destinations, ) SATISFIES LOWER(dest.src_answer) = ‘asd/asdas/j’ END

but i get an error [3000] syntax error - at end of input.

Can someone please help me and enlighten me what am i doing wrong?

each ANY must close with END

SELECT count(1) AS c`Preformatted text`nt
FROM trials AS t USE KEYS ["mapping:1686:2004:test"]
WHERE ANY m IN mappings
      SATISFIES LOWER(m.src_question) = "asd/asd"
                AND (ANY dest IN m.destinations
                    SATISFIES LOWER(dest.src_answer) = "asd/asdas/j"
                    END)
      END;

Thanks for the response such a stupid mistake it is working :slightly_smiling_face:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.