0

我正在尝试使用 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] 映射器 [label] 无法从类型 [string] 更改为 [completion]]

当我进行搜索时,出现以下错误

[class_cast_exception] org.elasticsearch.index.mapper.core.StringFieldMapper$StringFieldType 不能转换为 org.elasticsearch.index.mapper.core.CompletionFieldMapper$CompletionFieldType

4

1 回答 1

1

我解决了这个问题

curl -XDELETE localhost:9200/items
于 2016-03-20T15:20:08.283 回答