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

Allow storing aggregation pipelines as documents in MongoDB

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

      Currently it's not possible to store MongoDB's own aggregation pipelines due to the limitation that field names cannot start with a "$" symbol, and cannot contain a "." symbol either.

      For MongoDB to become the one-stop-shop for data storage, aggregation, massaging this is an unnecessary limitation that we should fix.

      Usage example: I want to build an app using custom / reusable aggregation pipelines that I can mix and match to get different views into my dataset.

      My current workaround is to replace all "$" symbols with "#" in MongoDB and recursively replace them back to "$" on the client. This is clumsy and expensive. I have not yet needed dot-notation fields.

      Two suggestions:
      a) either lift the limitations of storing field names with $-prefix and dots (could be escaped to not confuse with operators ($set, $push, etc), like

      db.foo.insert({
          "name": "my custom aggregation", 
          pipeline: [ {"\$match": {foo\.bar: 1} }, {"\$group": {_id: "bar", ...} } ],
      });
      

      b) or offer an alternative aggregation reserved symbol (# instead of $). For this alternative, we could allow both for the time being to not break backwards compatibility. This doesn't solve the dotted field name problem however.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            2 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: