[SERVER-17457] Inclusion of "null" in "distinct" result depends on existence of index Created: 04/Mar/15  Updated: 04/Mar/15  Resolved: 04/Mar/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.6.8
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Yonatan Most Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-14832 Distinct command result set may inclu... Needs Scheduling
Operating System: ALL
Steps To Reproduce:

> db.test_col.find()
{ "_id" : ObjectId("54f6c5dbf79146d1fdfd0766"), "test_field" : "test_value_1" }
{ "_id" : ObjectId("54f6c5dff79146d1fdfd0767") }
> db.test_col.distinct("test_field") 
[ "test_value_1" ]      <------------------ Without index - "null" not included
> db.test_col.createIndex({"test_field": 1})
{
        "createdCollectionAutomatically" : false,
        "numIndexesBefore" : 1,
        "numIndexesAfter" : 2,
        "ok" : 1
}
> db.test_col.distinct("test_field")
[ null, "test_value_1" ]  <------------------ With index - "null" included

Participants:

 Description   

When calling distinct on a field which is missing from some of the records, the result either includes or does not include null, depending on whether there is an index in that field.



 Comments   
Comment by J Rassi [ 04/Mar/15 ]

Hi,

Thanks for the report. This is a known issue, described in SERVER-14832. I'm resolving this ticket as duplicate. Feel free to add yourself as a watcher to SERVER-14832 for updates.

~ Jason Rassi

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