我在 mongo 下的数据库中有 3 个集合:节目 - 场地 - 下拉菜单
节目映射如下
"show": {
"properties" : {
"description": {
"type": "string"
},
"image": {
"type": "string"
},
"site": {
"type": "string"
},
"title" : {
"type" : "multi_field",
"fields" : {
"title" : {"type" : "string", "index" : "analyzed"},
"raw_title" : {"type" : "string", "index" : "not_analyzed", "store": "no"}
}
}
}
}
像这样的场地
"venues": {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" : "analyzed"},
"raw_name" : {"type" : "string", "index" : "not_analyzed", "store": "no"}
}
},
"city" : {
"type" : "multi_field",
"fields" : {
"city" : {"type" : "string", "index" : "analyzed"},
"raw_city" : {"type" : "string", "index" : "not_analyzed", "store": "no"}
}
},
"region" : {
"type" : "multi_field",
"fields" : {
"region" : {"type" : "string", "index" : "analyzed"},
"raw_region" : {"type" : "string", "index" : "not_analyzed", "store": "no"}
}
},
"state" : {
"type": "boolean"
}
}
}
我在 mongo 中有这个模型用于下拉菜单:
{
created: {
type: Date,
default: Date.now
},
analytics: {
type: String,
default: '',
trim: true
},
state: {
type: Boolean,
default: false,
index: true
},
show: {
type: Schema.ObjectId,
ref: 'Show'
},
venues:[{
venue:{
type: Schema.ObjectId,
ref: 'Venue',
index: true
},
site: {
type: String,
trim: true,
index: true
}
}]
}
我会将带有父/子架构的下拉列表映射到我的索引中,但我不明白是否可以使用 ObjectId,因为我已经尝试过使用此映射:
"dropdown": {
"properties" : {
"state": {
"type": "boolean"
},
"analytics": {
"type": "string"
},
"_parent":{
"type" : "show"
},
"venues" : {
"properties" : {
"venue" : {
"_parent": {
"type" : "venues"
}
}
},
"site" : {"type" : "string"}
}
}
}
但我收到了这个错误:
MapperParsingException[没有为属性指定类型 [显示]]
无论如何要正确设置我的索引?