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

Improve error message when certain operators are used in change streams

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization

      Spawned b/c of NODE-2162

      The code below produces the error "$match with $text is only allowed as the first pipeline stage", even though $match with $text is the only pipeline stage. Is there a subtle syntax error somewhere, or what else might be going on?

      const collectionChangeStream = collection.watch([
        { $match: { $text: { $search: 'cake' } } },
      ]);
       
      collectionChangeStream.on('change', next => {
        console.log(next);
      });
      

      The code above results in sending a pipeline to the server that looks something like this:

      [
        { $changeStream: { fullDocument: 'default' } },
        { $match: { $text: { $search: 'cake' } } }
      ]
      

      This is a result of an implementation detail of change streams. The error message "$match with $text is only allowed as the first pipeline stage" does not clearly identify to a user what exactly went wrong, and how they can fix it.

      Is it possible to have a more informative error message in this case?

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: