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

Having multiple $or clauses in a query results in the clauses being merged together

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.6
    • Querying
    • None
    • RHEL 6.1

    Description

      My understanding is that the default behavior when querying is for an implicit AND between fields being queried. But in the case of a query with multiple $or clauses the effect is for the clauses to be merged into one $or statement. So a query like:
      { $or : [

      { event : "e1" }

      ,

      { event : "e2" }

      ], $or [

      { host : "h1" }

      ,

      { host : "h2" }

      ] }

      I would have expected results containing only events e1 or e2 that are hosted by h1 or h2. But the actual results are document with events e1 or e2 or host h1 or h2. Is this the expected behavior or should the query hold true to the implicit AND between fields?

      NOTE: I can get the results I want by nesting the $or clauses within an $and.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mbarszcz Michael Barszcz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: