mongoosastic 4.x 和 elasticsearch 2.2 的建议完成问题
suggester completion issue with mongoosastic 4.x and elasticsearch 2.2
我正在尝试使用 mongoosastic 进行自动完成
我有以下代码:
var ItemSchema = new Schema({
label: {
type: String,
required: true,
es_type: "completion",
es_analyzer: "simple",
es_payloads: true
})
ItemSchema.plugin(mongoosastic);
var ITEM = mongoose.model('Item', ItemSchema);
ITEM.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);
}
});
在映射过程中,我收到了这条错误消息
[illegal_argument_exception] mapper [label] cannot be changed from
type [string] to [completion]]
当我进行搜索时,出现以下错误
[class_cast_exception]
org.elasticsearch.index.mapper.core.StringFieldMapper$StringFieldType
cannot be cast to
org.elasticsearch.index.mapper.core.CompletionFieldMapper$CompletionFieldType
我使用
解决了这个问题
curl -XDELETE localhost:9200/items
我正在尝试使用 mongoosastic 进行自动完成 我有以下代码:
var ItemSchema = new Schema({
label: {
type: String,
required: true,
es_type: "completion",
es_analyzer: "simple",
es_payloads: true
})
ItemSchema.plugin(mongoosastic);
var ITEM = mongoose.model('Item', ItemSchema);
ITEM.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);
}
});
在映射过程中,我收到了这条错误消息
[illegal_argument_exception] mapper [label] cannot be changed from type [string] to [completion]]
当我进行搜索时,出现以下错误
[class_cast_exception] org.elasticsearch.index.mapper.core.StringFieldMapper$StringFieldType cannot be cast to org.elasticsearch.index.mapper.core.CompletionFieldMapper$CompletionFieldType
我使用
解决了这个问题curl -XDELETE localhost:9200/items