Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1474

Ability to use count on embedded documents as a query condition for documents

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Environment:
      Universal
    • Query

      I am writing an application which tracks astronimical observations of targets. I have looked at documentation and it seems that I can use $elemMatch to find, for example, targets with at least one observation with (time > 1 week ago, type=photometry). However there doesn't seem to be a way to search for targets with at least 3 observations matching the criteria, or less than 2 matching observations etc.

      This would be the equivilent of:
      SELECT * FROM target JOIN observation [no need for ON clause because observation is embedded in target] WHERE observation.time>1281432059 AND observation.type='photometry' AND COUNT>=3 GROUP BY target.id

      More info is at http://groups.google.com/group/mongodb-user/browse_thread/thread/a34e0b9296c8a075

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            mike1989 Mike Worth
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: