Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-50544

Filtering on collection on deployment level change stream

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jdatta@imanisdata.com Joydip Datta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: