我想通过使用Mongoosastic给嵌套字段赋予弹性映射类型“嵌套”。我还想在嵌套字段中指定es_type
个字段。
我的模式如下:
const CarOwner = new Schema({
cars: [{
name: {
type: String,
es_indexed: true,
},
price: {
type: Number,
es_indexed: true,
es_type: 'float'
},
}],
});
我想要这个ElasticSearch映射:
{
"mappings": {
"carowner": {
"properties": {
"cars": {
"type": "nested",
"properties": {
"name": { "type": "text" },
"price": { "type": "float" },
}
}
}
}
}
}
我发现的唯一的Monososastic示例如下:
var Car = new Schema({
name: {
type: String,
es_indexed: true,
},
price: {
type: Number,
es_indexed: true,
es_type: 'float'
},
})
var CarOwner = new Schema({
cars: {
type:[Car],
es_indexed: true,
es_type: 'nested',
es_include_in_parent: true
}
})
我是否必须创建子模式,或者可以使用Mongoosastic创建我想要的映射吗?