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

Comment on: "manual/reference/operator/projection/positional.txt"

    XMLWordPrintable

    Details

    • Last comment by Customer:
      true
    • Sprint:
      KANBAN BUCKET

      Description

      "Both the $ operator and the $elemMatch operator project a subset of elements from an array based on a condition."

      This sentence reads like the $ operator will project multiple elements into the result, if more than one element of the array is matched by the query document. While one element is a subset it gives the impression that the operators could project multiple elements. The quoted sentence seems ambiguous and feels to me like it contradicts the first paragraph where it very clearly states the $ and $elemMatch only project the first element.

      The page about the $elemMatch projection operator has the same formulation.

      "The following query will return any embedded documents inside a grades array that have a mean of greater than 70 and a grade of greater than 90."

      I think this sentence is just factually wrong. The query below will only return the first document inside the grades array which matches the query.

      Unless I misunderstood how those operators work, clarifying some of the documentation would help others who are looking for a way to filter an array in the projected result. From what I understand the correct way is to use aggregation if you want a result which filters an array.

        Attachments

          Activity

            People

            Assignee:
            irene.smith Irene Smith
            Reporter:
            xgen-internal-docs Docs Collector User
            Participants:
            Last commenter:
            Jonathan Dahl Jonathan Dahl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

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