相关疑难解决方法(0)

为什么mongoosastic populate/elastic搜索没有填充我的一个引用?我得到一个空物

我有两个模型,我试图参考.风格和品牌.

Brand填充了所需的对象,但Style始终为空.

我已经尝试清除缓存/删除索引.有和没有include_in_parent和类型:'嵌套'.

我觉得它可能与指定的es_type等有关.不确定.


产品架构:

var mongoose = require('mongoose');
    var Schema = mongoose.Schema;
    var Style = require('./style');
    var Brand = require('./brand');
    var mongoosastic = require('mongoosastic');


    var ProductSchema = new mongoose.Schema({
      name: { type: String, lowercase: true , required: true},
      brand: {type: mongoose.Schema.Types.ObjectId, ref: 'Brand',
             es_type:'nested', es_include_in_parent:true},
        style: {type: mongoose.Schema.Types.ObjectId, ref: 'Style',
            es_schema: Style, es_type:'nested', es_include_in_parent: true},    
            year: { type: Number }
    });

    ProductSchema.plugin(mongoosastic, {
      hosts: [
        'localhost:9200'
      ],
      populate: [
        {path: 'style'},
        {path: 'brand'}
      ]
    });

    Product = module.exports = …
Run Code Online (Sandbox Code Playgroud)

mongoose node.js elasticsearch mongoosastic

6
推荐指数
1
解决办法
2417
查看次数

标签 统计

elasticsearch ×1

mongoosastic ×1

mongoose ×1

node.js ×1