In the Java mongo driver how do you do an or search?
In the mongo aggregation framework it is documented as $or. But when I try and use that as as match criteria it throws an invalid operation exception.
So I tried omitting the operation and using the following, (this is Groovy code but using the Java driver)
def r = getCollection(collectionName).aggregate(
[$match: [transactionType: [or: [1, 2]]],
[$group:
[_id: null,
sum: [$sum: '$property']]
]
).results()
But that doesn't work either. I've also tried removing the operator entirely and using just a List of values, but that also doesn't work.
I've tried looking throw the Java Mongo driver documentation but haven't found any mention of this. Anyone know the correct way to do an or operation here?