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

Support ordinary arithmetic parsing in Aggregation

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Aggregation Framework
    • Query

    Description

      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"]
        ]}
      ]}

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: