diff options
author | David Storch <david.storch@10gen.com> | 2017-10-10 19:08:11 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2017-10-13 17:58:01 -0400 |
commit | 744738bd23a5aed625dc1eed89851824fcf5e33a (patch) | |
tree | 1dbde58792c15fc42f5d6a064e306c0d6d7a5ab5 /jstests/core/fts_trailing_fields.js | |
parent | 10dbb695223d08dd5a4412e1319228496d606b13 (diff) | |
download | mongo-744738bd23a5aed625dc1eed89851824fcf5e33a.tar.gz |
SERVER-21011 Fix query correctness problem related to covered matching for 2d/text indexes.
The fix ensures that the tightness predicates over the
trailing fields of 2d/text indexes is checked. Predicates
which are INEXACT_FETCH will then get affixed to the FETCH
stage of the plan rather than incorrectly affixed to the
IXSCAN.
Diffstat (limited to 'jstests/core/fts_trailing_fields.js')
-rw-r--r-- | jstests/core/fts_trailing_fields.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/jstests/core/fts_trailing_fields.js b/jstests/core/fts_trailing_fields.js new file mode 100644 index 00000000000..2c7f79b423d --- /dev/null +++ b/jstests/core/fts_trailing_fields.js @@ -0,0 +1,22 @@ +// Tests for predicates which can use the trailing field of a text index. +(function() { + "use strict"; + + const coll = db.fts_trailing_fields; + + coll.drop(); + assert.commandWorked(coll.createIndex({a: 1, b: "text", c: 1})); + assert.writeOK(coll.insert({a: 2, b: "lorem ipsum"})); + + assert.eq(0, coll.find({a: 2, $text: {$search: "lorem"}, c: {$exists: true}}).itcount()); + assert.eq(1, coll.find({a: 2, $text: {$search: "lorem"}, c: null}).itcount()); + assert.eq(1, coll.find({a: 2, $text: {$search: "lorem"}, c: {$exists: false}}).itcount()); + + // An equality predicate on the leading field isn't useful, but it shouldn't cause any problems. + // Same with an $elemMatch predicate on one of the trailing fields. + coll.drop(); + assert.commandWorked(coll.createIndex({a: 1, b: "text", "c.d": 1})); + assert.writeOK(coll.insert({a: 2, b: "lorem ipsum", c: {d: 3}})); + assert.eq(0, coll.find({a: [1, 2], $text: {$search: "lorem"}}).itcount()); + assert.eq(0, coll.find({a: 2, $text: {$search: "lorem"}, c: {$elemMatch: {d: 3}}}).itcount()); +}()); |