1

I'm trying to import data located in a json file into an elasticsearch index using the curl command.

The index is being created using kibana as follow

  PUT employees
  {
    "mappings" : {
        "properties":{
            "fields": {
                "properties": {
                    "id": {"type": "text"},
                    "nom": {"type": "text"},
                    "prenom": {"type": "text"},
                    "sexe": {"type": "text"},
                    "socials": {
                        "properties": {
                            "name": {"type": "text"},
                            "url": {"type": "text"} 
                        }
                    },
                }
            }   
        }
    }
}

I'm running the follwing command to import the data

 curl -XPUT -H "Content-Type: application/json" localhost:9200/_bulk --data-binary @users.json

the users.json file contains the data represented as follow

 {"index": {"_index": "users", "_type": "user", "_id": 1}}
 {"fields": {"id": "5fe60ae52b40e53609c803ec","nom": "Jessica","prenom": "Herrera","aboutMe": "anim","socials": [{"name": "faacebook","url": "https://www.facebook.com/profile?id=5445546"},{"name": "linkedin","url": "https://www.linkedin.com/profile?id=5445546"}],"affiliations": [{"organisation": "ANARCO","equipe": "developpement","pays": "Russian Federation","dateD": "2013-06-03T00:00:00Z" ,"dateF": "2013-06-03T00:00:00Z" }]}}

Here is the error I get

 "type":"illegal_argument_exception","reason":"Rejecting mapping update to [users] as the final mapping would have more than 1 type 

I've read many resources but still not able to understand what I'm missing.

1 Answer 1

1

"type":"illegal_argument_exception","reason":"Rejecting mapping update to [users] as the final mapping would have more than 1 type

You are getting the above error because of the breaking changes in Elasticsearch 6.x, in which the mapping types were deprecated.

Indices created in Elasticsearch 7.0.0 or later no longer accept a default mapping. Indices created in 6.x will continue to function as before in Elasticsearch 6.x. Types are deprecated in APIs in 7.0, with breaking changes to the index creation, put mapping, get mapping, put template, get template and get field mappings APIs.

You need to modify your JSON as -

{"index": {"_index": "users", "_id": 1}}
{"fields": {"id": "5fe60ae52b40e53609c803ec","nom": "Jessica","prenom": "Herrera","aboutMe": "anim","socials": [{"name": "faacebook","url": "https://www.facebook.com/profile?id=5445546"},{"name": "linkedin","url": "https://www.linkedin.com/profile?id=5445546"}],"affiliations": [{"organisation": "ANARCO","equipe": "developpement","pays": "Russian Federation","dateD": "2013-06-03T00:00:00Z" ,"dateF": "2013-06-03T00:00:00Z" }]}}
Sign up to request clarification or add additional context in comments.

1 Comment

But doing this way, I cannot get a document by id, this http://localhost:9200/users/2 get request doesn't work, it gives me an incorrect http method for the uri users/2 error. Even if I give a default type like users/default/2 it doesn't return anything.

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.