Improve error message when certain operators are used in change streams

XMLWordPrintableJSON

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

      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:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Daniel Aprahamian (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: