Skip to content

Commit 0af3191

Browse files
author
Thomas Reggi
authored
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
1 parent 06a2444 commit 0af3191

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

lib/operations/create_indexes.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,35 @@ const MongoError = require('../core').MongoError;
77
const parseIndexOptions = require('../utils').parseIndexOptions;
88
const maxWireVersion = require('../core/utils').maxWireVersion;
99

10-
const validIndexOptions = new Set([
10+
const VALID_INDEX_OPTIONS = new Set([
11+
'background',
1112
'unique',
13+
'name',
1214
'partialFilterExpression',
1315
'sparse',
14-
'background',
1516
'expireAfterSeconds',
1617
'storageEngine',
1718
'collation',
18-
'bucketSize'
19+
20+
// text indexes
21+
'weights',
22+
'default_language',
23+
'language_override',
24+
'textIndexVersion',
25+
26+
// 2d-sphere indexes
27+
'2dsphereIndexVersion',
28+
29+
// 2d indexes
30+
'bits',
31+
'min',
32+
'max',
33+
34+
// geoHaystack Indexes
35+
'bucketSize',
36+
37+
// wildcard indexes
38+
'wildcardProjection'
1939
]);
2040

2141
class CreateIndexesOperation extends CommandOperationV2 {
@@ -42,7 +62,7 @@ class CreateIndexesOperation extends CommandOperationV2 {
4262
const indexSpec = { name, key: indexParameters.fieldHash };
4363
// merge valid index options into the index spec
4464
for (let optionName in options) {
45-
if (validIndexOptions.has(optionName)) {
65+
if (VALID_INDEX_OPTIONS.has(optionName)) {
4666
indexSpec[optionName] = options[optionName];
4767
}
4868
}

0 commit comments

Comments
 (0)