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

Readable Aggregation Formulas

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      When writing complex aggregation queries, the expressions can become difficult to read. Perhaps being able to provide a string that can be parsed to the current syntax might help simplifying expressions.

      Here is an example for a group stage:

      {
        $group: {
          _id: '$field',
          foo: {
            $add: ["$field1", {$multiply: ["$field2", {$subtract: [90,"$field3"]}]}]
          }
      }
      

      Compared to this:

      {
        $group: {
          _id: '$field',
          foo: "$field1 + $field2 * (90 - $field3)"
        }
      }
      

      A simple stack structure could be used to transform the latter into the former. Obviously, there are scenarios in which you couldn't use this syntax to mirror the current implementation, but that's not the intention either.

      I've been going through some of our large aggregation queries and a lot of them are just formulas that could be made a lot easier to read if such a feature existed.

            Assignee:
            asya.kamsky@mongodb.com Asya Kamsky
            Reporter:
            arg20 Gabriel Zimmermann
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: