Elastic Search with Mongoose - Embedded Schema
I have the following mongoose schema:
var ReviewSchema = new Schema({
title: String,
details: String,
user: {type: ObjectId, ref:'User'},
});
var SubjectSchema = new Schema({
name: {type: String, required: true},
website: {type: String, index: { unique: true }},
review: {type: [ReviewSchema], es_indexed:true}
});
I have another User schema which is referenced in Review.
I tried mongoosastic plugin but I can't find ways to index the referenced
schema. I want to index the name of the user of a review. So I just used
elastic search client for this.
Every create/update/delete of review, I looked up in the database and
update elastic search index with the value retrived from database. Is
there better way for this on updating index when embedded schema is
updated? Thanks
No comments:
Post a Comment