我在node.js服务器中设置mongoosastic时遇到了麻烦。 我跟着视频讲座,但它不起作用。
然而,人们说如果我降级弹性搜索版本,那就没关系了。 但我认为它应该能够与elasticsearch v2.2一起使用。
这是代码点亮。
var mongoose = require('mongoose');
var mongoosastic = require('mongoosastic');
var Schema = mongoose.Schema;
var ProductSchema = new Schema({
category : {type : Schema.Types.ObjectId, ref : 'Category'}
, name : String
, price : Number
, image : String
});
//Set Elastic Search
ProductSchema.plugin(mongoosastic, {
hosts : [
'localhost:9200'
]
});
module.exports = mongoose.model('Product', ProductSchema);
这是错误。
/Users/juneyoungoh/Documents/node_amazon/sample/node_modules/mongoosastic/lib/mongoosastic.js:14
return arr.filter && arr.length === (arr.filter(item => typeof item === 'str
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/juneyoungoh/Documents/node_amazon/sample/models/product.js:3:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/juneyoungoh/Documents/node_amazon/sample/routes/main.js:2:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/juneyoungoh/Documents/node_amazon/sample/server.js:83:18)
at Module._compile (module.js:456:26)
感谢您的帮助!
答案 0 :(得分:0)
自 Mongoosastic 的最新版本以来,它需要Node.js version >= 4.0
您可以在此处查看https://github.com/mongoosastic/mongoosastic/blob/master/CHANGELOG.md