使用Postman创建ElasticSearch索引时出错

juzqafwq  于 2022-11-07  发布在  Postman
关注(0)|答案(1)|浏览(215)

我正在尝试使用官方的javascript客户端创建一个带有Map的ElasticSearch索引。当我尝试在没有索引的情况下创建时,一切都很顺利,但在创建索引时,我遇到了一个错误。
下面是我的模式:

{
    "mappings":{
        "post":{
            "properties":{
                "city":{
                    "type": "text"
                },
                "contact_email":{
                    "type": "text"
                },
                "country":{
                    "type": "text"
                },
                "description":{
                    "type": "text"
                },
                "image":{
                    "type": "text"
                },
                "post_id":{
                    "type": "text"
                },
                "state_province":{
                    "type": "text"
                },
                "title":{
                    "type": "text"
                },
                "user_id":{
                    "type": "text"
                }
            }
        }
    }
}

当我执行上面的命令时,我得到这个错误:

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [post : {properties={country={type=text}, image={type=text}, post_id={type=text}, city={type=text}, user_id={type=text}, description={type=text}, state_province={type=text}, title={type=text}, contact_email={type=text}}}]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [post : {properties={country={type=text}, image={type=text}, post_id={type=text}, city={type=text}, user_id={type=text}, description={type=text}, state_province={type=text}, title={type=text}, contact_email={type=text}}}]",
        "caused_by": {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [post : {properties={country={type=text}, image={type=text}, post_id={type=text}, city={type=text}, user_id={type=text}, description={type=text}, state_province={type=text}, title={type=text}, contact_email={type=text}}}]"
        }
    },
    "status": 400
}
yduiuuwa

yduiuuwa1#

也许你想念布景。你可以试试这个

{
    "settings": {
        "number_of_shards": 2,
        "number_of_replicas": 1
    },
    "mappings": {
        "post": {
            "properties": {
                "city": {
                    "type": "text"
                },
                "contact_email": {
                    "type": "text"
                },
                "country": {
                    "type": "text"
                },
                "description": {
                    "type": "text"
                },
                "image": {
                    "type": "text"
                },
                "post_id": {
                    "type": "text"
                },
                "state_province": {
                    "type": "text"
                },
                "title": {
                    "type": "text"
                },
                "user_id": {
                    "type": "text"
                }
            }
        }
    }
}

相关问题