-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
ALL
Creating a compound index on fields of objects embedded in an array can change the behavior of queries on those fields. It's easiest to demonstrate this behavior using an example. In the test case below, see that querying using the index produces no results, while the same query using no index produces one result.
Test case:
> db.test.insert({ "_id" : 1, "arr" : [
,
{ "animal" : "dog", "size" : "medium" } ]});;
> db.test.ensureIndex(
);
> db.test.find(
);
> db.test.find(
).hint(
{ "$natural" : 1 });
{ "_id" : 1, "arr" : [
,
{ "animal" : "dog", "size" : "medium" }] }