0
私はmongoose
スキーマを持っています。これに対してセーブまたは更新が呼び出されると、弾性検索ソースも更新されます。 status
の値がdraft
の場合、弾性検索を更新しないでください。次のスキーマで変更を行うことでどのように達成できますか?マングースを使用したElastic Search Clientによる条件付き更新
var TestShcema = new mongoose.Schema({
custom_id:{
type:String,
required: true,
index: {unique: true},
es_indexed: true,
es_index:"analyzed",
es_index_analyzer:"autocomplete_analyzer"
},
title:{
type:String,
index: {unique: false},
es_indexed: true,
es_index:"analyzed",
es_index_analyzer:"autocomplete_analyzer"
},
status:{
type:String,
index: {unique: false},
es_indexed: true,
es_index:"analyzed",
es_index_analyzer:"autocomplete_analyzer"
}
});
//Hook with Elastic Search
var esClient = new elasticsearch.Client({host: config.elasticsearch.host});
TestShcema.plugin(mongoosastic, {
esClient: esClient
});
var Test = mongoose.model('Test', TestShcema);
module.exports = Test;