mongoose-elasticsearch-xp
mongoose-elasticsearch-xp copied to clipboard
Populate is not working and the value is ignored
trafficstars
when i am adding es_type in model the value is ignored from indexing I have two models category and products in that i need to populate the primarycategoryid. Category schema
import { Schema, model } from "mongoose";
var mexp = require('mongoose-elasticsearch-xp').v7;
var categorySchema = Schema({
title: {
type: String,
required: 'title required',
trim: true
},
description: {
type: String,
trim: true
},
imageurl: {
type: String
}
})
categorySchema.plugin(mexp);
// Export Category
var categoryModel = (module.exports = model("category", categorySchema));
Product Schema
import { Schema, model, } from "mongoose";
var mexp = require('mongoose-elasticsearch-xp').v7;
var productSchema = Schema({
productname: {
type: String,
required: "Product name required",
trim: true
},
description: {
type: String,
required: "Description required",
trim: true
},
shortdescription: {
type: String,
trim: true
},
pricing: [
{
baseprice: {
required: "Price required",
type: Number,
trim: true
},
offerprice: {
required: "Price required",
type: Number,
trim: true
}
}
],
primarycategoryid: {
type: Schema.Types.ObjectId,
required: "Primary Category id",
ref: 'category',
es_type: {
title: {
es_type: 'string'
}
}
},
thumbnailurl: {
type: String
},
});
productSchema.plugin(mexp);
// Export product
var productModel = (module.exports = model("product", productSchema));
But in elastic search the primarycategoryid is not there, when i am removing
es_type: { title: { es_type: 'text' } }
the primarycategoryid added