diff --git a/src/categories/topics.js b/src/categories/topics.js index 337357290c..2a3bd71e5a 100644 --- a/src/categories/topics.js +++ b/src/categories/topics.js @@ -90,7 +90,10 @@ module.exports = function (Categories) { var stop = data.stop === -1 ? data.stop : start + normalTidsToGet - 1; if (Array.isArray(set)) { - db[direction === 'highest-to-lowest' ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop }, next); + var weights = set.map(function (s, index) { + return index ? 0 : 1; + }); + db[direction === 'highest-to-lowest' ? 'getSortedSetRevIntersect' : 'getSortedSetIntersect']({ sets: set, start: start, stop: stop, weights: weights }, next); } else { db[direction === 'highest-to-lowest' ? 'getSortedSetRevRange' : 'getSortedSetRange'](set, start, stop, next); } diff --git a/test/database/sorted.js b/test/database/sorted.js index 123a48ecd2..c5f7101aff 100644 --- a/test/database/sorted.js +++ b/test/database/sorted.js @@ -661,6 +661,18 @@ describe('Sorted Set methods', function () { }); }); + it('should return the reverse intersection of two sets', function (done) { + db.getSortedSetRevIntersect({ + sets: ['interSet1', 'interSet2'], + start: 0, + stop: 2, + }, function (err, data) { + assert.ifError(err); + assert.deepEqual(['value3', 'value2'], data); + done(); + }); + }); + it('should return the intersection of two sets with scores aggregate MIN', function (done) { db.getSortedSetIntersect({ sets: ['interSet1', 'interSet2'],