我有一个模型模式,我想在ElasticSearch中索引它的一部分。根据文档,设置:
es_indexed: true与所需的模式字段一起,只对与ElasticSearch相关的操作进行索引。我有一个大约20个字段的大模式,其中只需要索引5个字段。
问题是,这些标志被忽略,整个文档被编入索引。
var PersonSchema = new Mongoose.Schema({
name: {type: String, es_indexed: true},
address: address: {
street_address: {type: String},
locality: {type: String},
region: {type: String},
zip: {type: String},
landmark: {type: String},
neighbourhood : {type: [String]}
},
...
tags: {type:[String], index:true, es_indexed: true},
...
})
PersonSchema.plugin(mongoosastic);
var Person = Mongoose.model("Merchant", PersonSchema);在我打电话之后
var stream = Merchant.synchronize()
, count = 0;
stream.on('data', function(err, doc){
count++;
console.log('indexing: '+ count+ ' done');
});
stream.on('close', function(){
console.log('indexed ' + count + ' documents!');
});
stream.on('error', function(err){
console.log(err);
});保存整个文档,包括地址和其他不必要的字段。为什么es_indexed: true标志不能工作?
发布于 2015-04-17 10:27:43
显然,您必须为所有字段提供一个es_indexed属性,以显式地说明是否包括该字段。
var PersonSchema = new Mongoose.Schema({
name: {type: String, es_indexed: true},
address: address: {
es_indexed: false, //Exclusion needs to be specified as well
street_address: {type: String},
locality: {type: String},
region: {type: String},
zip: {type: String},
landmark: {type: String},
neighbourhood : {type: [String]}
},
...
tags: {type:[String], index:true, es_indexed: true},
...
})https://stackoverflow.com/questions/29625511
复制相似问题