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

Failed when using $exist false check on a embedded array

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
    • Environment:
      1) CentOS 7
      2) Mongo DB version: 3.0.5 + wiredTiger
      3) C++ driver: legacy 1.0.1
    • Linux
    • Hide

      1) Create documents

      2) Create query object, and return the number of documents which doesn't have the field: app.qos

      BSONObj query = BSON("app.qos"<<"{$exists:false}");
      Query qos_query(query);
      int counter = conn->count(ns, qos_query);

      3) Check the result of count. the counter=0 (It should return 1)

      4) If run the shell command from command line, it return correctly.
      db.xxx.find( {"app.qos": { $exists: false}}).count()

      Show
      1) Create documents 2) Create query object, and return the number of documents which doesn't have the field: app.qos BSONObj query = BSON("app.qos"<<"{$exists:false}"); Query qos_query(query); int counter = conn->count(ns, qos_query); 3) Check the result of count. the counter=0 (It should return 1) 4) If run the shell command from command line, it return correctly. db.xxx.find( {"app.qos": { $exists: false}}).count()

      Two documents, (one has the array sub-doc: app.qos, the other doesn't have the array doc. could get the document which does has the array sub-document by query with

      {app.qos: $exist false}

      .
      {
      "_id" : "af16688e-b73c-480e-bfdb-1eef3de9453b",
      "str_id" : "ad071684-d713-4979-8064-bd4c4efea945",
      "app" : {
      "end_time" : ISODate("2016-01-15T17:33:26.842Z"),
      "qos" : [

      { "jitter" : 0, "loc_time_stamp" : NumberLong("3839365094"), "loc_tx_pkts" : 2, "loc_tx_oct" : 160, }

      ]
      }
      }

      {
      "_id" : "af16688e-b73c-480e-bfdb-1eef3de9453b",
      "str_id" : "ad071684-d713-4979-8064-bd4c4efea945",
      "app" :

      { "end_time" : ISODate("2016-01-15T17:33:26.842Z"), }

      }

            Assignee:
            Unassigned Unassigned
            Reporter:
            gabriel.wang gabriel.wang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: