Error While Creating an ElasticSearch index with Postman

  Kiến thức lập trình

I’m trying to create an elasticsearch index with mappings using the official javascript client. when I try to create without an index it all goes well, but while creating index I’m getting an error.

Here is my schema:

    {
    "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"
                }
            }
        }
    }
}

When I execute the command above, I get this error:

{
    "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
}

3

Maybe you miss setting. You can try this

{
    "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"
                }
            }
        }
    }
}

LEAVE A COMMENT