0

curl -H "Content-Type: application/json" -XPOST 'https://mydomain/' -d @cps_index.json

Contents in ths JSON file

{
"settings": {
    "mappings": {
        "_source": {
            "enabled": false
        },
        "cps": {
            "properties": {
                "firstName": {
                    "type": "text"
                },
                "lastname": {
                    "type": "text"
                },
                "email": {
                    "type": "text"
                },
                "mobileNumber": {
                    "type": "keyword"
                },
                "employeeId": {
                    "type": "keyword"
                }
            }
        }
    }
}

}

Failed with the Response Message {"error":"Incorrect HTTP method for uri [/] and method [POST], allowed: [GET, HEAD, DELETE]","status":405}

2 Answers 2

2

Several issues:

  • no index name
  • use PUT instead of POST
  • mappings is nested into settings

Do this instead:

Modify cps_index.json like this:

{
    "mappings": {
        "doc": {
            "_source": {
                "enabled": false
            },
            "properties": {
                "firstName": {
                    "type": "text"
                },
                "lastname": {
                    "type": "text"
                },
                "email": {
                    "type": "text"
                },
                "mobileNumber": {
                    "type": "keyword"
                },
                "employeeId": {
                    "type": "keyword"
                }
            }
        }
    }
}

Run this:

curl -H "Content-Type: application/json" -XPUT 'https://mydomain/indexname'
                                           ^                        ^
                                           |                        |
                                        use PUT              add index name
Sign up to request clarification or add additional context in comments.

2 Comments

I'm using 6.5 Version, When I use the above json. It still throws an error. Instead I used this and it worked { "mappings": { "_doc": { "_source": { "enabled": false }, "properties": { "firstName": { "type": "text" }, "lastName": { "type": "text" }, "email": { "type": "text" }, "mobileNumber": { "type": "keyword" }, "employeeId": { "type": "keyword" } } } } }
Yes, my bad, _source gores inside the mapping type. Fixed
1

You need to add the index name after https://mydomain

https://mydomain/indexname

2 Comments

I did that and i received this error {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: ......,"status":400}
Looks like it expects some type name. But since ES deprecating the type. I don't want to use type. What can I do here. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.