summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-06-08 07:50:48 -0400
committerJason Rassi <rassi@10gen.com>2015-06-08 07:50:48 -0400
commit66f165639a514a3ca764bab87dea5e7b1af0825f (patch)
tree19bbb236a4a5e0ecc80ccf02363cfa7fa3e63323
parent5bf56982d557a6c4e7d156b1e525950dd7960684 (diff)
downloadmongo-66f165639a514a3ca764bab87dea5e7b1af0825f.tar.gz
SERVER-17660 Rename index option "filter" to "partialIndexExpression"
-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, 26 insertions, 27 deletions
diff --git a/jstests/core/index_partial1.js b/jstests/core/index_partial1.js
index 4293d98ea0c..17a42622894 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 }, { filter : { a : { $lt : 5 } } } );
+ t.ensureIndex( { x : 1 }, { partialFilterExpression : { 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, filter : { a : { $lt : 5 } } } );
+ t.ensureIndex( { x : 1 }, { background : true, partialFilterExpression : { a : { $lt : 5 } } } );
assert.eq( 5, getNumKeys() );
t.dropIndex( { x : 1 } );
assert.eq( 1, t.getIndexes().length );
- t.ensureIndex( { x : 1 }, { filter : { a : { $lt : 5 } } } );
+ t.ensureIndex( { x : 1 }, { partialFilterExpression : { 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 }, { filter : 5 } ) );
- assert.commandFailed( t.ensureIndex( { x : 1 }, { filter : { x : { $asdasd : 3 } } } ) );
+ assert.commandFailed( t.ensureIndex( { x : 1 }, { partialFilterExpression : 5 } ) );
+ assert.commandFailed( t.ensureIndex( { x : 1 }, { partialFilterExpression : { x : { $asdasd : 3 } } } ) );
assert.eq( 1, t.getIndexes().length );
// Partial indexes can't also be sparse indexes.
- 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.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.eq( 2, t.getIndexes().length );
}
diff --git a/jstests/core/index_partial2.js b/jstests/core/index_partial2.js
index c79eb7631d7..2d2ed5d9268 100644
--- a/jstests/core/index_partial2.js
+++ b/jstests/core/index_partial2.js
@@ -4,8 +4,7 @@ t = db.index_filtered2;
t.drop();
t.ensureIndex( { x : 1 },
- { filter : { a : { $lt : 5 },
- b : { $lt : 5 } } } );
+ { partialFilterExpression : { 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 ef8f706f00a..4e9bb234b10 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 } , { filter : filter } );
+ var res = t.ensureIndex( { x : 1 } , { partialFilterExpression : filter } );
assert(!res.ok, tojson(res));
printjson(res);
}
diff --git a/jstests/core/index_partial4.js b/jstests/core/index_partial4.js
index e953976d072..76c5a45f495 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 } , { filter : { a : 1 } } );
+ t.ensureIndex( { x : 1 } , { partialFilterExpression : { 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 d72c1789557..f3a7091d04b 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 } , { filter : { b : { $exists : 1 } } } )
+ t.ensureIndex( { a : 1, b : 1 } , { partialFilterExpression : { 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 } , { filter : { a : { $exists : 1 }, b : { $exists : 1 }, c : { $exists : 1 } } } )
+ t.ensureIndex( { a : 1, b : 1, c : 1 } , { partialFilterExpression : { 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",
- filter : { a : { $exists : 1 }, b : { $exists : 1 }, c : { $exists : 1 } } } )
+ partialFilterExpression : { 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 }, { $filter: { b: { $exists: 1 } } })
+ t.ensureIndex({ b: 1, a: 1 }, { $partialFilterExpression: { 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 }, { $filter: { "b.c.d": { $exists: 1 } }, name : "index1" })
- t.ensureIndex({ "b.e.value": 1, "a": 1 }, { $filter: { "b.e.value": { $exists: 1 } }, name : "index2" })
+ 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" })
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 71391b5efc6..65e5fadc7d4 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,
- filter: {z: {$exists: true}}}));
+ partialFilterExpression: {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 ed30256319f..a111a9a6684 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 filtered indexes
+ // handle partial 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 cf6c7a90e67..5f230340b91 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 filter at top level");
+ "$and only supported in partialFilterExpression 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 filtered index: "
+ str::stream() << "unsupported expression in partial 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("filter");
+ BSONElement filterElement = spec.getField("partialFilterExpression");
if ( filterElement ) {
if ( isSparse ) {
return Status( ErrorCodes::CannotCreateIndex,
- "cannot mix \"filter\" and \"sparse\" options" );
+ "cannot mix \"partialFilterExpression\" and \"sparse\" options" );
}
if ( filterElement.type() != Object ) {
return Status(ErrorCodes::CannotCreateIndex,
- "'filter' for an index has to be a document");
+ "'partialFilterExpression' 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 24c0087b2c9..358b5a264d7 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("filter");
+ BSONElement filterElement = _descriptor->getInfoElement("partialFilterExpression");
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 48b460c1dcb..742e5a3ea16 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["filter"].eoo()),
+ _partial(!infoObj["partialFilterExpression"].eoo()),
_cachedEntry( NULL )
{
_indexNamespace = makeIndexNamespace( _parentNS, _indexName );