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

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

    XMLWordPrintableJSON

Details

    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

            irene.smith Irene Smith
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              6 years, 15 weeks, 1 day ago