|
|
@@ -207,13 +207,10 @@ SearchClient.prototype.deletePages = function(pages)
|
|
|
SearchClient.prototype.addAllPages = function()
|
|
|
{
|
|
|
var self = this;
|
|
|
- var offset = 0;
|
|
|
var Page = this.crowi.model('Page');
|
|
|
var cursor = Page.getStreamOfFindAll();
|
|
|
var body = [];
|
|
|
|
|
|
- var counter = 0;
|
|
|
-
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
cursor.on('data', function (doc) {
|
|
|
if (!doc.creator || !doc.revision || !self.shouldIndexed(doc)) {
|
|
|
@@ -228,6 +225,12 @@ SearchClient.prototype.addAllPages = function()
|
|
|
}).on('close', function () {
|
|
|
// all done
|
|
|
|
|
|
+ // return if body is empty
|
|
|
+ // see: https://github.com/weseek/crowi-plus/issues/228
|
|
|
+ if (body.length == 0) {
|
|
|
+ return resolve();
|
|
|
+ }
|
|
|
+
|
|
|
// 最後に送信
|
|
|
self.client.bulk({
|
|
|
body: body,
|