我正在尝试使用NodeJs的mongoosastic插件将现有的集合索引到ElasticSearch。这是我的方案:
const callCenterSchema = new mongoose.Schema({
_owner : { type: mongoose.Schema.Types.ObjectId, ref: 'User', es_type: 'object' },
ivrs: [{
name: {
type: String,
es_type: 'string'
},
ivrType: {
type: String,
default: 'mobile',
enum: ['mobile', 'website'],
es_type: 'string'
},
submenu: {
type: [ CallCenterSubmenu.schema ],
es_type: 'nested',
es_include_in_parent: true
}
}]
});
callCenterSchema.plugin(mongoosastic, {
esClient: require('tusla/lib/db/elastic').elastic,
populate: [
{ path: '_owner' }
]
});
let CallCenter = mongoose.model('CallCenter', callCenterSchema);
CallCenter.synchronize()
CallCenter.createMapping(function(err, mapping) {
if (err) {
console.error('Error creating mapping for CallCenters', err.message);
}
});
module.exports = CallCenter;我的子菜单模式是这样的:
const callcenterSubmenuSchema = new mongoose.Schema({
name: String,
key: String,
waitTime: {
type: Number
},
waitSuffix: String,
numberOrLink: String,
auth: {
canBeSkipped: String,
fields: {
type: Array,
es_type: 'object'
},
verification: String,
regExp: String
},
submenu: [this]
}, { _id: false });我一直收到这个特定的错误,但不能解决它。如果你们能帮我的话我很感激。
谢谢!
为CallCenters mapper_parsing_exception创建映射时出错字段子菜单上声明的混合类型没有处理程序
发布于 2016-08-03 06:56:43
我想问题出在这一行:
type: [ CallCenterSubmenu.schema ]在错误消息中,它说:
No handler for type [mixed] declared on field [submenu]因此,您试图将submenu字段的类型指定为fixed (或者elasticsearch推断它,因为我不确定),但据我所知,没有mixed类型。所以ES会触发这个异常。必须指定有效的类型:https://www.elastic.co/guide/en/elasticsearch/reference/master/mapping-types.html
https://stackoverflow.com/questions/38725441
复制相似问题