From 0af319191209319fcd18f6aaab278703d3f93c1a Mon Sep 17 00:00:00 2001 From: Thomas Reggi Date: Fri, 14 Aug 2020 15:55:00 -0400 Subject: [PATCH] fix: update full list of index options 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 --- lib/operations/create_indexes.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/operations/create_indexes.js b/lib/operations/create_indexes.js index 0540551d64..211b43cdcd 100644 --- a/lib/operations/create_indexes.js +++ b/lib/operations/create_indexes.js @@ -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 { @@ -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]; } }