From 3274c2a3d916cfc3e73c9020660fe4d0fb45ebf2 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Mon, 22 Feb 2021 19:05:35 -0500 Subject: SERVER-54706 Fix listIndexes with string-valued weight --- jstests/core/fts_blogwild.js | 4 +++- jstests/core/fts_index.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'jstests') diff --git a/jstests/core/fts_blogwild.js b/jstests/core/fts_blogwild.js index 29a2508bf07..f449b6b827e 100644 --- a/jstests/core/fts_blogwild.js +++ b/jstests/core/fts_blogwild.js @@ -16,8 +16,10 @@ t.save({ }); // default weight is 1 -// specify weights if you want a field to be more meaningull +// specify weights if you want a field to be more meaningful t.createIndex({dummy: "text"}, {weights: "$**"}); +// ensure listIndexes can handle a string-valued "weights" +assert.eq(2, t.getIndexes().length); res = t.find({"$text": {"$search": "blog"}}); assert.eq(3, res.length(), "A1"); diff --git a/jstests/core/fts_index.js b/jstests/core/fts_index.js index 3080534c434..c704159d67e 100644 --- a/jstests/core/fts_index.js +++ b/jstests/core/fts_index.js @@ -204,4 +204,19 @@ coll.dropIndexes(); assert.commandFailed(coll.createIndex({a: 1, _fts: "text", _ftsx: 1, c: 1}, {weights: {}})); assert.commandFailed(coll.createIndex({a: 1, _fts: "text", _ftsx: 1, c: 1})); +// These are permitted for now, make sure they don't interfere with listIndexes. +// TODO (SERVER-54712): Remove +coll.drop(); +assert.commandWorked(coll.createIndex({a: 1, c: 1}, {weights: {d: 1}})); +coll.getIndexes(); +coll.drop(); +assert.commandWorked(coll.createIndex({a: 1, c: 1}, {weights: "$**"})); +coll.getIndexes(); +coll.drop(); +assert.commandWorked(coll.createIndex({a: 1, c: 1}, {weights: {}})); +coll.getIndexes(); +coll.drop(); +assert.commandWorked(coll.createIndex({a: 1, c: 1}, {weights: "$foo"})); +coll.getIndexes(); + coll.drop(); -- cgit v1.2.1