elasticsearch,mongoose,mongoosastic,Node.js,Mongodb,elasticsearch,Mongoose,Mongoosastic" /> elasticsearch,mongoose,mongoosastic,Node.js,Mongodb,elasticsearch,Mongoose,Mongoosastic" />

Node.js 如何整合Mongoostic?

Node.js 如何整合Mongoostic?,node.js,mongodb,elasticsearch,mongoose,mongoosastic,Node.js,Mongodb,elasticsearch,Mongoose,Mongoosastic,全新的ELASTICSEARCH 我有一个猫鼬模式定义如下 const newSchema = new mongoose.Schema({ name: String, age: Number, interests: [Objects], }); newSchema.plugin(mongoosastic); New = module.exports = mongoose.model('New', newSchema); New.createMapping({

全新的
ELASTICSEARCH

我有一个
猫鼬模式
定义如下

const newSchema = new mongoose.Schema({
    name: String,
    age: Number,
    interests: [Objects],
});

newSchema.plugin(mongoosastic);

New = module.exports = mongoose.model('New', newSchema);

New.createMapping({
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0,
        "analysis": {
            "filter": {
                "nGram_filter": {
                    "type": "nGram",
                    "min_gram": 2,
                    "max_gram": 20,
                    "token_chars": [
                        "letter",
                        "digit",
                        "punctuation",
                        "symbol"
                    ]
                }
            },
            "analyzer": {
                "nGram_analyzer": {
                    "type": "custom",
                    "tokenizer": "whitespace",
                    "filter": [
                        "lowercase",
                        "asciifolding",
                        "nGram_filter"
                    ]
                },
                "whitespace_analyzer": {
                    "type": "custom",
                    "tokenizer": "whitespace",
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                }
            }
        }
    },
    "mappings": {
        "new": {
            "_all": {
                "analyzer": "nGram_analyzer",
                "search_analyzer": "whitespace_analyzer"
            },
            "properties": {
                "name": {
                    "type": "string",
                },
                "age": {
                    "type": "string",
                },
                "interests": {
                    "type": "string",
                },
            }
        }
    }
}, function(err, mapping) {
    if (err) {
        console.log('error');
        console.log(err);
    } else {
        console.log('mapping created!');
        console.log(mapping);
    }
});
当我运行上面的项目时,我会遇到这样的错误:

消息:'[mapper\u parsing\u exception]类型[string]没有处理程序 在字段[年龄]上声明'

我做错了什么?我对弹性搜索一无所知,猫鼬


我甚至对elasticsearch一无所知,上面的
createMapping
函数是从internet复制的。

elasticsearch已放弃字符串类型,现在使用文本。。使用“类型”:“文本”即使我尝试使用“文本”类型,它也不起作用。它显示相同的错误ElasticSearch已删除字符串类型,现在正在使用文本。。使用“类型”:“文本”即使我尝试使用“文本”类型,它也不起作用。它显示了相同的错误