[SERVER-22216] Failed when using $exist false check on a embedded array Created: 18/Jan/16  Updated: 14/Apr/16  Resolved: 18/Jan/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: gabriel.wang Assignee: Unassigned
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

1) CentOS 7
2) Mongo DB version: 3.0.5 + wiredTiger
3) C++ driver: legacy 1.0.1


Operating System: Linux
Steps To Reproduce:

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()

Participants:

 Description   

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"), }

}



 Comments   
Comment by Stennie Steneker (Inactive) [ 18/Jan/16 ]

Hi Gabriel,

Thanks for confirming this issue was due to incorrect query syntax.

Please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag where your questions will reach a large audience of MongoDB users, developers and enthusiasts.

Regards,
Stephen

Comment by gabriel.wang [ 18/Jan/16 ]

sorry for my typo.
The syntax of query is incorrect. it should be { app.qos: {$exists:false}.
I have resolved it, please close this ticket.

Comment by gabriel.wang [ 18/Jan/16 ]

The log captured in mongod.log as below.

[conn2] command xxx.$cmd command: count { count: "app", query: { app.qos: "{$exists:false}" } } planSummary: COLLSCAN keyUpdates:0 writeConflicts:0 numYields:459 reslen:44 locks:{ Global: { acquireCount:

{ r: 920 }

}, Database: { acquireCount:

{ r: 460 }

}, Collection: {acquireCount:

{ r: 460 }

} } 1923ms

Generated at Thu Feb 08 03:59:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.