azure - DocumentDB SQL check multiple values in array -
i using azure's documentdb database. have potentially thousands of documents , want return documents contain tags.
for example:
document 1
{ "id": "328732, "name": "jeff", "tags": [ "a", "b", "c" ] }
document 2
{ "id": "54092, "name": "ayla", "tags": [ "b", "d", "f" ] }
document 3
{ "id": "98234, "name": "lara", "tags": [ "b", "g", "h" ] }
if have list of tags ["a", "f", "x"]
, first 2 documents (jeff, , ayla) should returned. can achieve using built in function array_contains
several or
operators:
select * c array_contains(c.groups, "a") or array_contains(c.groups, "f") or array_contains(c.groups, "x")
i'm wondering if there better way achieve this. if had hundreds of tags need hundreds of conditions.
i know of no other way achieve want. write code automatically expand series of array_contains
or
s.
Comments
Post a Comment