Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13883

Investigate changes in SERVER-30405: add expression to generate a random number

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.7.0, 4.4.2
    • manual, Server
    • None
    • 5
    • ServerDocs2020: Oct27 - Nov3, ServerDocs2020: Nov3 - Nov 10, ServerDocs2020: Nov10 - Nov 17, ServerDocs2020: Nov17 - Nov 24, ServerDocs2020: Nov24 - Dec1, ServerDocs2020: Dec1 - Dec8, ServerDocs2020: Dec8 - Dec15, ServerDocs2020: Dec15 - Jan 5, ServerDocs2020: Jan5 - Jan12, ServerDocs2020: Jan12 - Jan19
    • true

    Description

      Description

      Downstream Change Summary

      We added a new expression, {$rand:{}} which generates a random number between 0 and 1 (as a float). It takes no arguments.

      $rand returns a different value every time it is called. If instead you want to pick a single random number to use for the whole query, you can call $rand in a command-level let variable.

      Description of Linked Ticket

      For generating a random number during aggregation or something like SERVER-22225 it would be nice to have a way to generate a (pseudo-)random number, either as an expression or an a system variable.

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

      Attachments

        Issue Links

          Activity

            People

              dave.cuthbert@mongodb.com Dave Cuthbert
              backlog-server-pm Backlog - Core Eng Program Management Team
              Githook User Githook User
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                1 year, 30 weeks, 5 days ago