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

No longer permit $meta in exclusion projections; parse $meta in find as inclusion by default

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Optimization

      This arose from SERVER-83756:

      1. Currently, $meta is legal in exclusion projections. E.g., the following is a legal pipeline:
      [{ $project: {"about" : 0, "score": { "$meta": "textScore" }}}]

      Other than id, $meta is the _only exception to the "don't mix inclusion and exclusion projections" rule.

      For more explanation & documentation on how this is currently problematic in the code, see first two sections of: https://docs.google.com/document/d/1IrjexstlwIYkoWEmwpHZOLz64ad5R4MdU3dVwpV-17c/edit?usp=sharing 

      1. Currently, $meta in find is parsed by default as exclusion. E.g., the following is parsed as an exclusion projection:
      {foo: {$meta: 'sortKey'}} 

      The default behavior for some $func expression is to parse it as an inclusion projection.

      Began work on this as part of SERVER-83756, but ended up resolving it with a workaround as it became clear that these changes would be significant.

      As a starting point, documentation of initial work that was done: https://docs.google.com/document/d/1fN026Wo_LI0lrwylj1JJ1wN7pWIujUj0rj9kPU8AqKY/edit?usp=sharing 

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            reilly.mcbride@mongodb.com Reilly McBride
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: