How to create docs in index using API?

What I understand _type is not required now.

So first scenario:

POST host/_bulk

{ "index":{ "_index": "myindex"} }
{ "name":"john doe","age":25 }

Does not work

Scenario 2:
POST host/myindex/_bulk

{ "index":{ } }
{ "name":"john doe","age":25 }

Does not work

Scenario 3:
POST host/myindex/_type/_bulk

{ "index":{ } }
{ "name":"john doe","age":25 }

Does not work

What is the correct query?

I'd use for now:

POST /myindex/_doc/_bulk
{ "index": { } }
{ "name": "john doe", "age": 25 }
1 Like

Thank you. Looks like '_doc' causes error.

#! Deprecation: [types removal] Specifying types in bulk requests is deprecated.
{
"took" : 113,
"errors" : false,
"items" : [
{
"index" : {
"_index" : "test_index",
"_type" : "_doc",
"_id" : "aJEqS3UBcGLv9iq-EsyO",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1,
"status" : 201
}
}
]
}

Without it, it's fine.

Right. The right way is to send:

DELETE /myindex
POST /myindex/_bulk
{ "index": { } }
{ "name": "john doe", "age": 25 }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.