N1QL with or statement or union

Hi Team,
I have below JSON document, Type for these documents will vary as per requirement.
“Id”: “abc::14835”,
“$Type”: “abc”,
“$MdfdById”: “yyy”,
“$MdfdTmstmp”: “2020-06-23T15:18:13.263Z”,
“RunStats”: [ { “Transaction”: “abc”,
“Status”: “Inprogress”,
“BatchId": “yyyyyyy”,
“CreateTime”: “2020-06-23T15:18:13.263Z”,
“ValidForMins”: “9999”,
“RecCount”: “98”
} ]
Now to get the RunStats.Status i have below query,
select RunStat.Status from masterdata-source as d UNNEST RunStats AS RunStat
where d.$Type=‘abc’ or d.$Type=‘efg’ or d.$Type=‘hij’

Can i change this to union and make each one separate query or this one is fine? i wanted to know best optimal solution.


You can use Union or IN . make sure each one has index or single index.

where d. $Type IN [‘abc’, ‘efg’, ‘hij’]