|
|
@ -463,6 +463,13 @@ describe('Indexes', function () { |
|
|
|
idx.insert(doc1); |
|
|
|
idx.insert(doc1); |
|
|
|
idx.insert(doc2); |
|
|
|
idx.insert(doc2); |
|
|
|
idx.insert(doc3); |
|
|
|
idx.insert(doc3); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('bloup'), []); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('hello'), [doc1]); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('world'), [doc3]); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('yes'), []); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching(undefined), [doc2]); |
|
|
|
|
|
|
|
|
|
|
|
idx.insert(doc4); |
|
|
|
idx.insert(doc4); |
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('bloup'), []); |
|
|
|
assert.deepEqual(idx.getMatching('bloup'), []); |
|
|
@ -472,6 +479,33 @@ describe('Indexes', function () { |
|
|
|
assert.deepEqual(idx.getMatching(undefined), [doc2, doc4]); |
|
|
|
assert.deepEqual(idx.getMatching(undefined), [doc2, doc4]); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('Can get all documents for which a field is null', function () { |
|
|
|
|
|
|
|
var idx = new Index({ fieldName: 'tf' }) |
|
|
|
|
|
|
|
, doc1 = { a: 5, tf: 'hello' } |
|
|
|
|
|
|
|
, doc2 = { a: 2, tf: null } |
|
|
|
|
|
|
|
, doc3 = { a: 8, tf: 'world' } |
|
|
|
|
|
|
|
, doc4 = { a: 7, tf: null } |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
idx.insert(doc1); |
|
|
|
|
|
|
|
idx.insert(doc2); |
|
|
|
|
|
|
|
idx.insert(doc3); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('bloup'), []); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('hello'), [doc1]); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('world'), [doc3]); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('yes'), []); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching(null), [doc2]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
idx.insert(doc4); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('bloup'), []); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('hello'), [doc1]); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('world'), [doc3]); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching('yes'), []); |
|
|
|
|
|
|
|
assert.deepEqual(idx.getMatching(null), [doc2, doc4]); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('Can get all documents for a given key in a sparse index, but not unindexed docs (= field undefined)', function () { |
|
|
|
it('Can get all documents for a given key in a sparse index, but not unindexed docs (= field undefined)', function () { |
|
|
|
var idx = new Index({ fieldName: 'tf', sparse: true }) |
|
|
|
var idx = new Index({ fieldName: 'tf', sparse: true }) |
|
|
|
, doc1 = { a: 5, tf: 'hello' } |
|
|
|
, doc1 = { a: 5, tf: 'hello' } |
|
|
|