2014-03-27 19:24:03 -04:00
|
|
|
// Test creation of compound indexes with special index types.
|
|
|
|
|
|
|
|
|
|
var coll = db.index_plugins;
|
|
|
|
|
coll.drop();
|
|
|
|
|
|
|
|
|
|
// Test building special index types on a single field.
|
|
|
|
|
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "hashed"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "2d"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "2dsphere"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "text"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "geoHaystack"}, {bucketSize: 1})); // compound required
|
2014-03-27 19:24:03 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
// Test compounding special index types with an ascending index.
|
2014-03-27 19:24:03 -04:00
|
|
|
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "2dsphere", b: 1}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: 1, b: "2dsphere"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "text", b: 1}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: 1, b: "text"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "2d", b: 1}));
|
|
|
|
|
coll.dropIndexes();
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: 1, b: "2d"})); // unsupported
|
2014-03-27 19:24:03 -04:00
|
|
|
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "geoHaystack", b: 1}, {bucketSize: 1}));
|
|
|
|
|
coll.dropIndexes();
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: 1, b: "geoHaystack"}, {bucketSize: 1})); // unsupported
|
2014-03-27 19:24:03 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "hashed", b: 1})); // unsupported
|
|
|
|
|
assert.commandFailed(coll.ensureIndex({a: 1, b: "hashed"})); // unsupported
|
2014-03-27 19:24:03 -04:00
|
|
|
|
|
|
|
|
// Test compound index where multiple fields have same special index type.
|
|
|
|
|
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "2dsphere", b: "2dsphere"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
assert.commandWorked(coll.ensureIndex({a: "text", b: "text"}));
|
|
|
|
|
coll.dropIndexes();
|
|
|
|
|
|
2016-03-17 14:41:31 -04:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "2d", b: "2d"})); // unsupported
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "geoHaystack", b: "geoHaystack"}, // unsupported
|
2014-03-27 19:24:03 -04:00
|
|
|
{bucketSize: 1}));
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "hashed", b: "hashed"})); // unsupported
|
2014-03-27 19:24:03 -04:00
|
|
|
|
|
|
|
|
// Test compounding different special index types with each other.
|
|
|
|
|
|
2016-03-17 14:41:31 -04:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "2d", b: "hashed"})); // unsupported
|
|
|
|
|
assert.commandFailed(coll.ensureIndex({a: "hashed", b: "2dsphere"})); // unsupported
|
|
|
|
|
assert.commandFailed(coll.ensureIndex({a: "2dsphere", b: "text"})); // unsupported
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "text", b: "geoHaystack"})); // unsupported
|
2016-03-17 14:41:31 -04:00
|
|
|
assert.commandFailed(coll.ensureIndex({a: "geoHaystack", b: "2d"}, // unsupported
|
2014-03-27 19:24:03 -04:00
|
|
|
{bucketSize: 1}));
|