Skip to content

Commit 72cd6af

Browse files
committed
Update the test-search to the current stable ES API
1 parent ffc0eac commit 72cd6af

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

lib/readable-search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ReadableHits.prototype._fetchNextPage = function() {//size) {
5353
self.emit('error', e);
5454
return self.push(null);
5555
}
56-
self.total = resp.hits.hits.length;
56+
self.total = resp.hits.total;
5757
self._hits = resp.hits.hits;
5858
self.from += self._hits.length;
5959
if (self.from >= self.total) {

test/test-search.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('When getting documents by id', function() {
7878
index: 'myindex',
7979
type: 'mytype',
8080
body: {
81-
docs: { ids: docs }
81+
ids: docs
8282
}
8383
}, callback);
8484
};
@@ -110,6 +110,7 @@ function populateIndex(nb, done) {
110110
cmds.push({ index: { _index: 'myindex', _type: 'mytype', _id: rec._id } });
111111
cmds.push(rec);
112112
ids.push(rec._id);
113+
rec._id = undefined;
113114
}
114115
client.bulk({
115116
body: cmds
@@ -135,16 +136,19 @@ function checkRecords(rs, ts, nb, done) {
135136
};
136137
var errClosure = function(e) {
137138
err = e;
139+
var complete = done;
140+
done = null;
141+
return complete(e);
138142
};
139143
rs.on('error', errClosure);
140144
ws.on('error', errClosure);
141145
if (ts) {
142146
ts.on('error', errClosure);
143147
}
144148
function onFinish() {
145-
if (err) { return done(err); }
149+
if (err) { return done && done(err); }
146150
expect(hits.length).to.equal(nb);
147-
done();
151+
done && done();
148152
}
149153
if (ts) {
150154
rs.pipe(ts).pipe(ws).on('finish', onFinish);

test/test-write.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ describe('When writing', function() {
2626
});
2727

2828
var transformToBulk = new TransformToBulk(function(doc) {
29-
return { _id: doc._id };
29+
var docId = doc._id;
30+
doc._id = undefined;
31+
return { _id: docId };
3032
});
3133
// drop the index then
3234
client.indices.delete({index: 'myindex2'}, function() {

0 commit comments

Comments
 (0)