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

Support ordinary arithmetic parsing in Aggregation

    • 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
    • Query

      Arithmetic expressions in Aggregation must now be coded by hand in a rather quirky JSON prefix notation of the form {$opName: ["$field1", "$field2"]}. This becomes unwieldy and impractical with expressions of even moderate complexity, as the operands themselves become JSON subdocuments.

      The server could better perform this function by accepting an expression in conventional infix operator precedence notation as used by most programming languages, of the form {$arithmetic: "field1 opSymbol field2"}. For example,

      {$arithmetic: "a * b + c / (d - e)"}

      would translate to

      {$add:[
        {$multiply: ["$a", "$b"]},
        {$divide: [
          "$c", 
          {$subtract: ["$d", "$e"]
        ]}
      ]}

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            chris.biow Chris Biow
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: