[SERVER-14952] count and find inconsistent when using $not and a regex Created: 19/Aug/14 Updated: 03/Sep/14 Resolved: 03/Sep/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.4.3, 2.4.10 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Roelof Spijker | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
I have a simple collection containing documents with 2 fields each:
There is a single default index on the collection on the _id field. Now, when I perform a query like:
I get results, as expected. However, when I perform a query like:
I get no results. Even though
returns 11000. If I perform a .explain() on the find query, it tells me that it scanned all ~40K objects in the collection and that n is in fact 11000. A db.collection.find(...).count() gives me 11000 as well. A db.collection.find(...).hasNext() gives me false though. I've tried this on two separate systems (2.4.10 and 2.4.3) with the exact same result. I've tried $not: {/regex/}on other databases in the same system and it works fine. So it seems to be related to the data in this specific collection. Some example documents (without _id):
So, here I would expect the query to match the 3rd document. In fact, importing this small test and running the query displays the problem. I've attached a .json file which can be imported with mongoimport --jsonArray. The documents were imported using mongoimport from a file containing a jsonArray with the exact amount of documents as were imported into the DB. |
| Comments |
| Comment by Ramon Fernandez Marina [ 03/Sep/14 ] |
|
rspijker, thanks for your report, this is a duplicate of an existing ticket: As for JSON formatting, JIRA wants things wrapped in {code}...{code} directives to do a nice formatting. Regards, |
| Comment by Roelof Spijker [ 19/Aug/14 ] |
|
I'm not sure why JIRA messed up the formatting on the JSON. I assure you, it's properly formatted in my files/shell. |