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

MongoDB ignores some hint'ed queries on array fiels (e.g., array: {$gt: [10]}) in v2.2.3

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Querying
    • None
    • Server Triage
    • ALL

    Description

      While performing an academic experiment based on the random generation of a large set of tests to exercise the Query Language of MongoDB (all of which syntactically valid), a possible bug was detected in some preliminary trial tests.

      Comparing an array field to an array of values (e.g., {$gt: ["a", "b"] or ["a"]}) instead of a single value (e.g., "a" or "b") on a hint()'ed query returns erroneous results.

      • hint()'ing on the _id field (with or without creating a custom index with ensureIndex) returns results but cursor.count() and cursor.size() both return 0.
      • hint()'ing on a custom index returns no results and cursor.count() and cursor.size() both return 0.
      • without hint()'ing but with the custom index created no results are returned and cursor.count() and cursor.size() both return 0.
      • the same query but without hint()'ing and with no custom indexes created results in the array portion of the query being ignored.

      Examples:

      find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]) results in the same as

      find({notArray: {$lt: 1000}}) meaning that the array portion of the query is ignored

      -------------------------------------------------------------------------------------------

      ensureIndex({notArray: 1})

      find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]) no results and cursor.count() and cursor.size() both return 0

      find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]).hint("id") shows results in the shell but cursor.count() and cursor.size() both return 0

      find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]).hint("notArray_1") no results and cursor.count() and cursor.size() both return 0

       

       

      Attachments

        Activity

          People

            backlog-server-triage Backlog - Triage Team
            jagnelo@student.dei.uc.pt João Agnelo
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: