Skip to content

Commit

Permalink
fix: update full list of index options
Browse files Browse the repository at this point in the history
Back-port of index options from master. In 3.5 this list was a block-list, and in 3.6 and 4.0 was updated to be an allow-list, but missing the complete list of options. This caused an issue where we accidentally dropped support for language options.

NODE-2755
  • Loading branch information
Thomas Reggi committed Aug 14, 2020
1 parent 06a2444 commit 0af3191
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions lib/operations/create_indexes.js
Expand Up @@ -7,15 +7,35 @@ const MongoError = require('../core').MongoError;
const parseIndexOptions = require('../utils').parseIndexOptions;
const maxWireVersion = require('../core/utils').maxWireVersion;

const validIndexOptions = new Set([
const VALID_INDEX_OPTIONS = new Set([
'background',
'unique',
'name',
'partialFilterExpression',
'sparse',
'background',
'expireAfterSeconds',
'storageEngine',
'collation',
'bucketSize'

// text indexes
'weights',
'default_language',
'language_override',
'textIndexVersion',

// 2d-sphere indexes
'2dsphereIndexVersion',

// 2d indexes
'bits',
'min',
'max',

// geoHaystack Indexes
'bucketSize',

// wildcard indexes
'wildcardProjection'
]);

class CreateIndexesOperation extends CommandOperationV2 {
Expand All @@ -42,7 +62,7 @@ class CreateIndexesOperation extends CommandOperationV2 {
const indexSpec = { name, key: indexParameters.fieldHash };
// merge valid index options into the index spec
for (let optionName in options) {
if (validIndexOptions.has(optionName)) {
if (VALID_INDEX_OPTIONS.has(optionName)) {
indexSpec[optionName] = options[optionName];
}
}
Expand Down

0 comments on commit 0af3191

Please sign in to comment.