-
Type:
Question
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I am trying to setup a deployment level change stream with a pipeline filter on collection name using MongoDB java SDK. Here is the code snippet.
List<Bson> pipeline = Collections.singletonList(Aggregates.match(Filters.or(
Filters.eq("namespace", "db1.c1"),
Filters.eq("namespace", "db1.c2"))));
client.watch(pipeline)
.fullDocument(FullDocument.UPDATE_LOOKUP).cursor()
.forEachRemaining(doc -> {
System.out.println(doc);
});
But this query does not match any document. Following variations of the pipeline document does not work either.
List<Bson> pipeline =
Collections.singletonList(Aggregates.match(Filters.or(
Document.parse("{'namespace': 'db1.c1'}"),
Document.parse("{'namespace': 'db1.c2'}"))));
Surprisingly pipeline works on other fields of the changestream document. For example, this works:
List<Bson> pipeline = Collections
.singletonList(Aggregates.match(Filters.and(
Document.parse("{'fullDocument.seq': 4}"),
Filters.in("operationType", Arrays.asList("insert")))));
I am not sure why this would be the case. I would appreciate any help in this regard.