简体   繁体   中英

Unable to cerate elasticsearch mapping using postman

I'm running elasticsearch image using docker.
Other services are running fine, like creating index, getting list of indices index.
But when i try to create mappings for already existing indices it returns the following error

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters: mappings definition"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:mappings definition "
    },
    "status": 400
}

This is the mapping i'm trying to create

{

                "mappings": {
                    "myfile": {
                       "dynamic": "strict",
                        "properties": {
                            "property1":{
                                "type":"keyword"
                            },
                            "property2":{
                                "type":"long"
                            }
                        }

                    }
                }
    }

URL i'm using to create mappings through postman Method POST http://localhost:9200/my-domain-name/_mapping in the body of the request i'm sending above mappings

Elasticsearch image for docker is

elasticsearch:
    container_name: tqd-elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.type=single-node
    depends_on:
      - "localstack"
    logging:
      driver: none
    ports:
      - 9300:9300
      - 9200:9200
    networks:
      - "local"
networks:
  local:
    driver: "bridge"

What am I doing wrong over here?

Elasticsearch has deprecated _type of index from Elasticsearch 7.x version.

You can use below request from Postamn and it will work for you.

URL: POST http://localhost:9200/my-domain-name/_mapping

{
  "dynamic": "strict",
  "properties": {
    "property1": {
      "type": "keyword"
    },
    "property2": {
      "type": "long"
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM