私のスキーマは次のようになりますmongoose
。
var LocationSchema = new Schema({
id: ObjectId,
geo: {
type: {
type: String,
required: true,
enum: ['Point', 'LineString', 'Polygon'],
default: 'Point'
},
coordinates: [{
type: Number,
es_lat_lon: true,
es_type: 'geo_point'
}]
}
});
mongoosastic
次に、プラグインを追加mongoose
してモデルを開始し、マッピングを作成しますmongoosastic
var esClient = new elasticsearch.Client({
host: config.es_url,
requestTimeout: Infinity,
keepAlive: true
});
LocationSchema.plugin(mongoosastic, { esClient: esClient })
var Location = mongoose.model('Location', LocationSchema);
/**
* mongoosastic create mappings
*/
Location.createMapping(function(err, mapping) {
if (err) {
console.log('error creating mapping (you can safely ignore this)');
console.log(err);
} else {
console.log('mapping created!');
console.log(mapping);
}
});
今、私はこのエラーを受け取ります[Error: MapperParsingException[No handler for type [{default=Point, enum=[Point, LineString, Polygon], required=true, type=string}] declared on field [geo]]]
ログの完全なエラー:
{
[Error: MapperParsingException[No handler for type [{default=Point, enum=[Point, LineString, Polygon], required=true, type=string}] declared on field [geo]]]
status: '400',
displayName: 'BadRequest',
message: 'MapperParsingException[No handler for type [{default=Point, enum=[Point, LineString, Polygon], required=true, type=string}] declared on field [geo]]'
}
私の質問は、私がこれを完全に間違っているのですか、それとも何か小さなものを見逃しているだけですか? 私がこれを行っている方法は、問題がmongoose
あるだけであり、その理由を理解していますが、これに最初に遭遇することはできません(問題が発生しているmongoosastic
理由は、タイプがあることを見て期待していないためです-少なくとも、それが問題を抱えていると思います)。mongoosastic
type