Monsgoosastic es_indexed 不工作
Monsgoosastic es_indexed not working
我有一个模型模式,我想在 ElasticSearch 中索引其中的一部分。根据docs,设置:
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
标志不起作用?
显然,您必须为所有字段提供 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},
...
})
我有一个模型模式,我想在 ElasticSearch 中索引其中的一部分。根据docs,设置:
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
标志不起作用?
显然,您必须为所有字段提供 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},
...
})