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

Investigate changes in SERVER-48474: Add $sampleRate match expression

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.7.0, 4.4.2
    • Component/s: manual, Server
    • Labels:
      None
    • Last comment by Customer:
      true
    • Story Points:
      3
    • Sprint:
      ServerDocs2020: Nov3 - Nov 10, ServerDocs2020: Nov10 - Nov 17, ServerDocs2020: Nov17 - Nov 24, ServerDocs2020: Nov24 - Dec1, ServerDocs2020: Dec1 - Dec8

      Description

      Description

      Downstream Change Summary

      We added a new expression, $sampleRate, which lets you select a desired fraction or percentage of documents. (Contrast with $sample, which lets you select a desired number of documents.)

      Description of Linked Ticket

      This match expression takes a floating point number between 0 and 1 (both inclusive) with 0 matching nothing and 1 matching all. It desugars to {$expr: {$rand: ...}}

      Unlike $sample, which is an experession, $sampleRate is a match-expression, which can go inside .find() or {$match: _}.

      For example, the pipeline:

      {$match: {$sampleRate: 0.25}}
      

      Would select on average 1/4 of the input documents. It could desugar to

      {$match: {$expr: {$lt: [ {$rand: {}}, 0.25 ]}}}
      

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dave.cuthbert Dave Cuthbert
              Reporter:
              backlog-server-pm Backlog - Core Eng Program Management Team
              Participants:
              Last commenter:
              Dave Cuthbert
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since reply:
                11 weeks, 4 days ago
                Date of 1st Reply: