|
|
|
@ -524,6 +524,29 @@ describe('Database', function () { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('Can use indexes for comparison matches', function (done) { |
|
|
|
|
d.ensureIndex({ fieldName: 'tf' }, function (err) { |
|
|
|
|
d.insert({ tf: 4 }, function (err, _doc1) { |
|
|
|
|
d.insert({ tf: 6 }, function (err, _doc2) { |
|
|
|
|
d.insert({ tf: 4, an: 'other' }, function (err, _doc3) { |
|
|
|
|
d.insert({ tf: 9 }, function (err, _doc4) { |
|
|
|
|
var data = d.getCandidates({ r: 6, tf: { $lte: 9, $gte: 6 } }) |
|
|
|
|
, doc2 = _.find(data, function (d) { return d._id === _doc2._id; }) |
|
|
|
|
, doc4 = _.find(data, function (d) { return d._id === _doc4._id; }) |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
data.length.should.equal(2); |
|
|
|
|
assert.deepEqual(doc2, { _id: doc2._id, tf: 6 }); |
|
|
|
|
assert.deepEqual(doc4, { _id: doc4._id, tf: 9 }); |
|
|
|
|
|
|
|
|
|
done(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}); // ==== End of '#getCandidates' ==== //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|