[SERVER-17890] index_partial_exists.js uses invalid index option "$filter" Created: 06/Apr/15  Updated: 27/Apr/15  Resolved: 22/Apr/15

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

Type: Bug Priority: Major - P3
Reporter: Michael Grundy Assignee: Michael Grundy
Resolution: Duplicate Votes: 0
Labels: 32qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-18180 Clean up partial_index tests for styl... Closed
Operating System: ALL
Steps To Reproduce:

db.coll.ensureIndex(

{ b: 1, a: 1 }

, {$$$filter: { b:

{ $exists: 1 }

} });

Sprint: Quint Iteration 3.1.2
Participants:

 Description   

In the partial index specification $filter is accepted as well as filter (like lines 105,140 & 141 in index_partial_exists.js does). $filter is also accepted with as many $$$ in front of filter as you can fit. The extra $ are stored in the index spec.

 
> db.coll.ensureIndex({ b: 1, a: 1 }, {$$$filter: { b: { $exists: 1 } } })
{
	"raw" : {
		"localhost:27018" : {
			"createdCollectionAutomatically" : true,
			"numIndexesBefore" : 1,
			"numIndexesAfter" : 2,
			"ok" : 1
		}
	},
	"ok" : 1
}
 
> db.coll.getIndexSpecs()
[
	{
		"v" : 1,
		"key" : {
			"_id" : 1
		},
		"name" : "_id_",
		"ns" : "test.coll"
	},
	{
		"v" : 1,
		"key" : {
			"b" : 1,
			"a" : 1
		},
		"name" : "b_1_a_1",
		"ns" : "test.coll",
		"$$$filter" : {
			"b" : {
				"$exists" : 1
			}
		}
	}
]



 Comments   
Comment by J Rassi [ 06/Apr/15 ]

The server currently ignores unknown index options (e.g. "$filter", "gFilterFish", etc). This is being tracked in SERVER-769.

See, for example:

> db.foo.insert({a:1,b:-1})
WriteResult({ "nInserted" : 1 })
> db.foo.ensureIndex({a:1},{$filter:{b:{$gt:0}}})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> db.foo.validate().keysPerIndex
{ "test.foo.$_id_" : 1, "test.foo.$a_1" : 1 } // a_1 index includes key for document => "$filter" is ignored.
>

I'll leave this ticket open to track the issue with index_partial_exists.js.

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