Home > Software engineering >  Unable to create elasticsearch mapping using postman
Unable to create elasticsearch mapping using postman

Time:12-27

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?

CodePudding user response:

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"
    }
  }
}
  • Related