ElasticSearch와 mongoosastic을 사용하여 MongoDB와 ElasticSearch간에 데이터를 동기화합니다.ElongSearch에 Mongo '_id'필드가 추가되지 않았습니다.
내가 겪고있는 문제는 ElasticSearch의 데이터를 검색 할 때 개체의 '_id'속성을 반환하지 않는다는 것입니다. 내가 잘못 말하고 있기 때문에 가능성이 높지만 문서를 찾을 수 없습니다.
내가 몽고에서 ElasticSearch에 동기화 mongoosastic 이야기하고있는 객체의 더미 예는 다음과 같습니다 :
var userSchema = new mongoose.Schema({
name: {type:String,es_indexed:true},
phone: {type:String,es_indexed:true},
settings:{type:[String],es_indexed:true,index:'not_analyzed'}
}, {id: true});
userSchema.plugin(mongoosastic,settings.elasticSearch);
var User = mongoose.model('User', userSchema);
User.createMapping(function(err, mapping){
if(err){
console.log('error creating User mapping (you can safely ignore this)');
console.log(err);
}else{
console.log('User mapping created!');
console.log(mapping);
}
});
내가 실행할 때 이 ElasticSearch에 _search, 나는 다음과 같은 구조
와 결과를 얻을 수{
"_index": "users",
"_type": "user",
"_id": "54b3ea9619160d0b0080d751",
"_score": 1,
"_source": {
"name": "John Smith",
"phone": "[email protected]",
"settings": []
}
}
_source 개체에 mongo 개체의 _id를 가져 오는 방법에 대한 아이디어가 있으십니까?
'_source'에서 실제로 필요합니까? ' "_id": "54b3ea9619160d0b0080d751"'이 (가) 관련 ID가 아닙니까? – pickypg