...
Starting in 5.0, the 'weights' field became a reserved field for text indexes. This is an issue for deployments that were upgraded from older versions to 5.0+, because they may still have non-text indexes with this 'weights' field. This causes mongosync processes syncing data from a source cluster with the above to error out because mongosync tries to re-create the same indexes on the destination cluster that's on MongoDB 5.0. mongosync uses the ignoreUnknownIndexOptions when creating indexes, which avoids most instances of invalid index fields but this did not work for the 'weights' field (see reproduction notes below).
xgen-internal-githook commented on Tue, 22 Aug 2023 10:24:57 +0000: Author: {'name': 'Alberto Massari', 'email': 'alberto.massari@mongodb.com', 'username': 'albymassari'} Message: SERVER-78369 Allow index options only for the correct index types Branch: v5.0 https://github.com/mongodb/mongo/commit/0be43c47849e154eb5ef814bd2149372478d841c xgen-internal-githook commented on Mon, 21 Aug 2023 09:01:08 +0000: Author: {'name': 'Alberto Massari', 'email': 'alberto.massari@mongodb.com', 'username': 'albymassari'} Message: SERVER-78369 Allow index options only for the correct index types Branch: v7.0 https://github.com/mongodb/mongo/commit/bc836934bcc8423c26cedce898c2233a8ec62e13 xgen-internal-githook commented on Wed, 9 Aug 2023 15:02:58 +0000: Author: {'name': 'Alberto Massari', 'email': 'alberto.massari@mongodb.com', 'username': 'albymassari'} Message: SERVER-78369 Allow index options only for the correct index types Branch: v6.0 https://github.com/mongodb/mongo/commit/978895b30b06d98cb10462fd7639f4dd3e86475a stef.wang commented on Tue, 8 Aug 2023 15:59:55 +0000: alberto.massari@mongodb.com Would the server team consider backporting this to 6.0 versions? This is currently affecting customers trying to live migrate to MongoDB Atlas 6.0.8+. xgen-internal-githook commented on Wed, 19 Jul 2023 18:43:53 +0000: Author: {'name': 'Alberto Massari', 'email': 'alberto.massari@mongodb.com', 'username': 'albymassari'} Message: SERVER-78369 Allow index options only for the correct index types Branch: master https://github.com/mongodb/mongo/commit/055b10cac1f473b58332a7311bdc28a125531dc0 xgen-internal-githook commented on Tue, 18 Jul 2023 15:19:40 +0000: Author: {'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'} Message: Revert "SERVER-78369 Allow index options only for the correct index types" This reverts commit fb6c4e3210bfdc387210feff5de738f67fc5da72. Branch: master https://github.com/mongodb/mongo/commit/d87c058bce250862d2bdbc0d44c526ea4026f23a xgen-internal-githook commented on Mon, 17 Jul 2023 19:23:07 +0000: Author: {'name': 'Alberto Massari', 'email': 'alberto.massari@mongodb.com', 'username': 'albymassari'} Message: SERVER-78369 Allow index options only for the correct index types Branch: master https://github.com/mongodb/mongo/commit/fb6c4e3210bfdc387210feff5de738f67fc5da72 JIRAUSER1269757 commented on Mon, 10 Jul 2023 15:31:22 +0000: The fix that was supposed to ignore bad keywords used in index definition, but it has simply created a list of allowed keywords regardless of the index type. So, "weight" is not removed because it's a valid keyword for FTS indexes, even if it is used in a plain index
1. Start a MongoDB 5.0 mongod process 2. Try to create an index that contains the field 'weights': db.runCommand({ createIndexes: "test", indexes: [{key: { key: 1, value: 1 }, name: "index_name", weights: {key: 1, name: 1}}], ignoreUnknownIndexOptions: true }) This should result in an error like this: MongoServerError: Error in specification { key: { key: 1, value: 1 }, name: "index_name", weights: { key: 1, name: 1 } } :: caused by :: Invalid index specification { key: { key: 1, value: 1 }, name: "index_name", weights: { key: 1, name: 1 } }; the field 'weights' can only be specified with text indexes