Add an option to the $sample stage to specify weights to use in the sampling.

XMLWordPrintableJSON

    • Query Optimization
    • Fully Compatible
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Specifying this option would prevent any optimized random cursor implementation from the storage engine, and would always use a top-k random sort, with the random value used to sort being multiplied by the specified weight.

      For example:

      db.example.aggregate([{
          $sample: {
              size: 100,
              weight: "$myWeightField"
          }
      }]);
      

              Assignee:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Lukas Wagner
              Votes:
              1 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated: