summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/index_partial1.js16
-rw-r--r--jstests/core/index_partial2.js3
-rw-r--r--jstests/core/index_partial3.js2
-rw-r--r--jstests/core/index_partial4.js2
-rw-r--r--jstests/core/index_partial_exists.js12
-rw-r--r--jstests/noPassthrough/ttl_partial_index.js2
-rw-r--r--src/mongo/db/catalog/collection_info_cache.cpp2
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp10
-rw-r--r--src/mongo/db/catalog/index_catalog_entry.cpp2
-rw-r--r--src/mongo/db/index/index_descriptor.h2
10 files changed, 27 insertions, 26 deletions
diff --git a/jstests/core/index_partial1.js b/jstests/core/index_partial1.js
index 17a42622894..4293d98ea0c 100644
--- a/jstests/core/index_partial1.js
+++ b/jstests/core/index_partial1.js
@@ -4,7 +4,7 @@ function runTest() {
t = db.index_filtered1;
t.drop();
- t.ensureIndex( { x : 1 }, { partialFilterExpression : { a : { $lt : 5 } } } );
+ t.ensureIndex( { x : 1 }, { filter : { a : { $lt : 5 } } } );
for ( i = 0; i < 10; i++ ) {
t.insert( { x : i, a : i } );
@@ -35,12 +35,12 @@ function runTest() {
t.dropIndex( { x : 1 } );
assert.eq( 1, t.getIndexes().length );
- t.ensureIndex( { x : 1 }, { background : true, partialFilterExpression : { a : { $lt : 5 } } } );
+ t.ensureIndex( { x : 1 }, { background : true, filter : { a : { $lt : 5 } } } );
assert.eq( 5, getNumKeys() );
t.dropIndex( { x : 1 } );
assert.eq( 1, t.getIndexes().length );
- t.ensureIndex( { x : 1 }, { partialFilterExpression : { a : { $lt : 5 } } } );
+ t.ensureIndex( { x : 1 }, { filter : { a : { $lt : 5 } } } );
assert.eq( 5, getNumKeys() );
t.dropIndex( { x : 1 } );
@@ -53,15 +53,15 @@ function runTest() {
// make sure I can't create invalid indexes
- assert.commandFailed( t.ensureIndex( { x : 1 }, { partialFilterExpression : 5 } ) );
- assert.commandFailed( t.ensureIndex( { x : 1 }, { partialFilterExpression : { x : { $asdasd : 3 } } } ) );
+ assert.commandFailed( t.ensureIndex( { x : 1 }, { filter : 5 } ) );
+ assert.commandFailed( t.ensureIndex( { x : 1 }, { filter : { x : { $asdasd : 3 } } } ) );
assert.eq( 1, t.getIndexes().length );
// Partial indexes can't also be sparse indexes.
- assert.commandFailed( t.ensureIndex( { x : 1 }, { partialFilterExpression : { a : 1 }, sparse: true } ) );
- assert.commandFailed( t.ensureIndex( { x : 1 }, { partialFilterExpression : { a : 1 }, sparse: 1 } ) );
- assert.commandWorked( t.ensureIndex( { x : 1 }, { partialFilterExpression : { a : 1 }, sparse: false } ) );
+ assert.commandFailed( t.ensureIndex( { x : 1 }, { filter : { a : 1 }, sparse: true } ) );
+ assert.commandFailed( t.ensureIndex( { x : 1 }, { filter : { a : 1 }, sparse: 1 } ) );
+ assert.commandWorked( t.ensureIndex( { x : 1 }, { filter : { a : 1 }, sparse: false } ) );
assert.eq( 2, t.getIndexes().length );
}
diff --git a/jstests/core/index_partial2.js b/jstests/core/index_partial2.js
index 2d2ed5d9268..c79eb7631d7 100644
--- a/jstests/core/index_partial2.js
+++ b/jstests/core/index_partial2.js
@@ -4,7 +4,8 @@ t = db.index_filtered2;
t.drop();
t.ensureIndex( { x : 1 },
- { partialFilterExpression : { a : { $lt : 5 }, b : { $lt : 5 } } } );
+ { filter : { a : { $lt : 5 },
+ b : { $lt : 5 } } } );
for ( i = 0; i < 10; i++ ) {
t.insert( { x : i, a : i, b : i } );
diff --git a/jstests/core/index_partial3.js b/jstests/core/index_partial3.js
index 4e9bb234b10..ef8f706f00a 100644
--- a/jstests/core/index_partial3.js
+++ b/jstests/core/index_partial3.js
@@ -5,7 +5,7 @@ t.drop();
t.insert( { x : 1 } );
function badFilter(filter) {
- var res = t.ensureIndex( { x : 1 } , { partialFilterExpression : filter } );
+ var res = t.ensureIndex( { x : 1 } , { filter : filter } );
assert(!res.ok, tojson(res));
printjson(res);
}
diff --git a/jstests/core/index_partial4.js b/jstests/core/index_partial4.js
index 76c5a45f495..e953976d072 100644
--- a/jstests/core/index_partial4.js
+++ b/jstests/core/index_partial4.js
@@ -3,7 +3,7 @@ function runTest() {
t = db.index_filtered4;
t.drop();
- t.ensureIndex( { x : 1 } , { partialFilterExpression : { a : 1 } } );
+ t.ensureIndex( { x : 1 } , { filter : { a : 1 } } );
function getNumKeys() {
var res = t.validate(true);
diff --git a/jstests/core/index_partial_exists.js b/jstests/core/index_partial_exists.js
index f3a7091d04b..d72c1789557 100644
--- a/jstests/core/index_partial_exists.js
+++ b/jstests/core/index_partial_exists.js
@@ -9,7 +9,7 @@ function runTest() {
t.insert( { _id : 2, a : 2 } )
t.insert( { _id : 1, a : 1, b : 1 } )
- t.ensureIndex( { a : 1, b : 1 } , { partialFilterExpression : { b : { $exists : 1 } } } )
+ t.ensureIndex( { a : 1, b : 1 } , { filter : { b : { $exists : 1 } } } )
assert.eq( 2 , t.getIndexes().length , "A1: correct number of indexes was created" )
assert.eq( 3 , t.find().sort( { a : 1, b : 1 } ).count() , "A2: sort().count() returns all records" )
@@ -32,7 +32,7 @@ function runTest() {
// build index first, then insert data + small variation of above
t.drop()
- t.ensureIndex( { a : 1, b : 1, c : 1 } , { partialFilterExpression : { a : { $exists : 1 }, b : { $exists : 1 }, c : { $exists : 1 } } } )
+ t.ensureIndex( { a : 1, b : 1, c : 1 } , { filter : { a : { $exists : 1 }, b : { $exists : 1 }, c : { $exists : 1 } } } )
assert.eq( 2 , t.getIndexes().length , "B1: correct number of indexes was created" )
t.insert( { _id : 4 } )
@@ -79,7 +79,7 @@ function runTest() {
t.insert( { _id : 3, a : 3 } )
t.insert( { _id : 4 } )
t.createIndex( { a : 1, b : 1 } , { name : "a_1_b_1_filtered",
- partialFilterExpression : { a : { $exists : 1 }, b : { $exists : 1 }, c : { $exists : 1 } } } )
+ filter : { a : { $exists : 1 }, b : { $exists : 1 }, c : { $exists : 1 } } } )
assert.eq( 3 , t.getIndexes().length , "C1: correct number of indexes was created" )
// Verify that queries work also with the 2 near-identical indexes
@@ -102,7 +102,7 @@ function runTest() {
// Same tests as in the beginning, but the filtered column is the first one
t.drop()
- t.ensureIndex({ b: 1, a: 1 }, { $partialFilterExpression: { b: { $exists: 1 } } })
+ t.ensureIndex({ b: 1, a: 1 }, { $filter: { b: { $exists: 1 } } })
assert.eq( 2 , t.getIndexes().length , "D1: correct number of indexes was created" )
t.insert( { _id : 4, b : 5 } )
@@ -136,8 +136,8 @@ function runTest() {
// Sub documents, Arrays (multikey index) and regular expressions
t.drop()
- t.ensureIndex({ "b.c.d": 1, "a": 1 }, { $partialFilterExpression: { "b.c.d": { $exists: 1 } }, name : "index1" })
- t.ensureIndex({ "b.e.value": 1, "a": 1 }, { $partialFilterExpression: { "b.e.value": { $exists: 1 } }, name : "index2" })
+ t.ensureIndex({ "b.c.d": 1, "a": 1 }, { $filter: { "b.c.d": { $exists: 1 } }, name : "index1" })
+ t.ensureIndex({ "b.e.value": 1, "a": 1 }, { $filter: { "b.e.value": { $exists: 1 } }, name : "index2" })
assert.eq( 3 , t.getIndexes().length , "E1: correct number of indexes was created" )
t.insert(
diff --git a/jstests/noPassthrough/ttl_partial_index.js b/jstests/noPassthrough/ttl_partial_index.js
index 65e5fadc7d4..71391b5efc6 100644
--- a/jstests/noPassthrough/ttl_partial_index.js
+++ b/jstests/noPassthrough/ttl_partial_index.js
@@ -9,7 +9,7 @@
// Create TTL partial index.
assert.commandWorked(coll.ensureIndex({x: 1}, {expireAfterSeconds: 0,
- partialFilterExpression: {z: {$exists: true}}}));
+ filter: {z: {$exists: true}}}));
var now = new Date();
assert.writeOK(coll.insert({x: now, z: 2}));
diff --git a/src/mongo/db/catalog/collection_info_cache.cpp b/src/mongo/db/catalog/collection_info_cache.cpp
index a111a9a6684..ed30256319f 100644
--- a/src/mongo/db/catalog/collection_info_cache.cpp
+++ b/src/mongo/db/catalog/collection_info_cache.cpp
@@ -110,7 +110,7 @@ namespace mongo {
}
}
- // handle partial indexes
+ // handle filtered indexes
const IndexCatalogEntry* entry = i.catalogEntry(descriptor);
const MatchExpression* filter = entry->getFilterExpression();
if (filter) {
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index 5f230340b91..cf6c7a90e67 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -450,7 +450,7 @@ namespace {
case MatchExpression::AND:
if (level > 0)
return Status(ErrorCodes::CannotCreateIndex,
- "$and only supported in partialFilterExpression at top level");
+ "$and only supported in filter at top level");
for (size_t i = 0; i < expression->numChildren(); i++) {
Status status = _checkValidFilterExpressions(expression->getChild(i),
level + 1 );
@@ -468,7 +468,7 @@ namespace {
return Status::OK();
default:
return Status(ErrorCodes::CannotCreateIndex,
- str::stream() << "unsupported expression in partial index: "
+ str::stream() << "unsupported expression in filtered index: "
<< expression->toString());
}
}
@@ -554,16 +554,16 @@ namespace {
const bool isSparse = spec["sparse"].trueValue();
// Ensure if there is a filter, its valid.
- BSONElement filterElement = spec.getField("partialFilterExpression");
+ BSONElement filterElement = spec.getField("filter");
if ( filterElement ) {
if ( isSparse ) {
return Status( ErrorCodes::CannotCreateIndex,
- "cannot mix \"partialFilterExpression\" and \"sparse\" options" );
+ "cannot mix \"filter\" and \"sparse\" options" );
}
if ( filterElement.type() != Object ) {
return Status(ErrorCodes::CannotCreateIndex,
- "'partialFilterExpression' for an index has to be a document");
+ "'filter' for an index has to be a document");
}
StatusWithMatchExpression res = MatchExpressionParser::parse( filterElement.Obj() );
if ( !res.isOK() ) {
diff --git a/src/mongo/db/catalog/index_catalog_entry.cpp b/src/mongo/db/catalog/index_catalog_entry.cpp
index 358b5a264d7..24c0087b2c9 100644
--- a/src/mongo/db/catalog/index_catalog_entry.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry.cpp
@@ -101,7 +101,7 @@ namespace mongo {
_head = _catalogHead( txn );
_isMultikey = _catalogIsMultikey( txn );
- BSONElement filterElement = _descriptor->getInfoElement("partialFilterExpression");
+ BSONElement filterElement = _descriptor->getInfoElement("filter");
if ( filterElement.type() ) {
invariant( filterElement.isABSONObj() );
BSONObj filter = filterElement.Obj();
diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h
index 742e5a3ea16..48b460c1dcb 100644
--- a/src/mongo/db/index/index_descriptor.h
+++ b/src/mongo/db/index/index_descriptor.h
@@ -68,7 +68,7 @@ namespace mongo {
_isIdIndex(isIdIndexPattern( _keyPattern )),
_sparse(infoObj["sparse"].trueValue()),
_unique( _isIdIndex || infoObj["unique"].trueValue() ),
- _partial(!infoObj["partialFilterExpression"].eoo()),
+ _partial(!infoObj["filter"].eoo()),
_cachedEntry( NULL )
{
_indexNamespace = makeIndexNamespace( _parentNS, _indexName );