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

Make $elemMatch support single object

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Duplicate
    • 2.1.0
    • None
    • Querying

    Description

      Currently $elemMatch only supports array values, so queries such as {foo: {$elemMatch:

      {a:1, b:2}

      }} will match {foo:[

      {a:1, b:2, c:3}

      ]}, but not {foo: {a:1, b:2, c:3}}. I know this can be easily done by query

      {'foo.a':1, 'foo.b':2}

      , but this behavior is inconsistent with other query operations; e.g.

      {a:1}

      will match both

      {a:[1]}

      and

      {a:1}

      .

      I'm currently writing a DSL for mongo, and I find it hard to explain this inconsistency to users. But I don't know if changing this will affect query optimizer.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zefei Zefei Xuan
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: