elasticsearch 在Keystonejs中使用Mongoostic索引现有集合时出现问题,elasticsearch,keystonejs,mongoosastic,elasticsearch,Keystonejs,Mongoosastic" /> elasticsearch 在Keystonejs中使用Mongoostic索引现有集合时出现问题,elasticsearch,keystonejs,mongoosastic,elasticsearch,Keystonejs,Mongoosastic" />

elasticsearch 在Keystonejs中使用Mongoostic索引现有集合时出现问题

elasticsearch 在Keystonejs中使用Mongoostic索引现有集合时出现问题,elasticsearch,keystonejs,mongoosastic,elasticsearch,Keystonejs,Mongoosastic,我在Keystone中开发了一些Mongoostic模型,它们通过以下方式进行了更新: Test.schema.plugin(mongoosastic); 但是,当我尝试使用有文档记录的方法同步/索引现有集合()以提取所有以前的条目时: BookSchema.plugin(mongoosastic); var Book = mongoose.model('Book', BookSchema) , stream = TestSchema.synchronize() , count =

我在Keystone中开发了一些Mongoostic模型,它们通过以下方式进行了更新:

Test.schema.plugin(mongoosastic);
但是,当我尝试使用有文档记录的方法同步/索引现有集合()以提取所有以前的条目时:

BookSchema.plugin(mongoosastic);

var Book = mongoose.model('Book', BookSchema)
  , stream = TestSchema.synchronize()
  , count = 0;

stream.on('data', function(err, doc){
  count++;
});
stream.on('close', function(){
  console.log('indexed ' + count + ' documents!');
});
stream.on('error', function(err){
  console.log(err);
});
我得到一个错误:

var TestSchema = mongoose.model('Test', Test)
           ^

ReferenceError: mongoose is not defined
显然,这是行不通的,所以我尝试用
keystone.list
替换
mongoose.model

stream = keystone.list('Test').synchronize();
但后来我得到了一个挥霍:

ReferenceError: Unknown keystone list {"paths":{"_id":{"path":"_id","instance":"ObjectID","validators":[],"setters":[null],"getters":[],"options":{"auto":true},"_index":null},"slug":{"enumValues":[],"regExp":null,"path":"slug","instance":"String","validators":[],"setters":[],"getters":[],"options":{"index":{"unique":true}},"_index":{"unique":true}},"createdAt":{"path":"createdAt"
结束时:

if (!ret) throw new ReferenceError('Unknown keystone list ' + JSON.stringify(arg));
                  ^

ReferenceError: Unknown keystone list "Test"

看起来应该很简单。。。有人知道我错过了什么吗?请非常感谢您的帮助!Fanks.

如果要从
TestSchema
同步数据,应使用:

var stream=TestSchema.model.synchronize()
或者,如果您想从keystone列表中获取它:

var stream=keystone.list('Test').model.synchronize()

这里重要的是,您只能在模型上调用
sychronize
方法


希望这有帮助

如果要从
TestSchema
同步数据,应使用:

var stream=TestSchema.model.synchronize()
或者,如果您想从keystone列表中获取它:

var stream=keystone.list('Test').model.synchronize()

这里重要的是,您只能在模型上调用
sychronize
方法

希望这有帮助