【发布时间】:2018-07-19 11:48:11
【问题描述】:
我已经安装了 Elasticsearch 和 Kibana。我有一个使用 NOdejs 和 MongoDB 的应用程序。这是我的架构配置:
var userSchema = new mongoose.Schema({
_id : { type: ObjectIdSchema , dropDups: true } ,
username : { type: String } ,
email : { type: String } ,
password : { type: String } ,
created : { type: String } ,
});
var Users = mongoose.model('Users', userSchema);
userSchema.plugin(mongoosastic,{
host:"127.0.0.1",
port: 9200,
protocol: "http",
index : "Users",
type: "Users",
});
Users.createMapping(function(err, mapping){
if(err){
console.log('error creating mapping (you can safely ignore this)');
console.log(err);
}else{
console.log('mapping created!');
console.log(mapping);
}
});
但是我收到了这个错误:
Users.createMapping(function(err, mapping){
^
TypeError: Users.createMapping is not a function
我也试过了,但遇到了同样的错误:
Users.createMapping({
"analysis" : {
"analyzer":{
"content":{
"type":"custom",
"tokenizer":"whitespace"
}
}
}
},function(err, mapping){
// do neat things here
});
我该如何解决?
【问题讨论】:
标签: node.js mongodb elasticsearch mongoosastic