# ES 5.0 - op\_type=create ERROR

**URL:** <https://discuss.elastic.co/t/es-5-0-op-type-create-error/64423>\
**Category:** Elasticsearch\
**Created:** [October 31, 2016, 9:55am UTC](https://discuss.elastic.co/t/es-5-0-op-type-create-error/64423 "2016-10-31T09:55:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bobo\_the\_Monkey](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@Bobo\_the\_Monkey](https://discuss.elastic.co/u/Bobo_the_Monkey)\
**Post date:** [October 31, 2016, 9:55am UTC](https://discuss.elastic.co/t/es-5-0-op-type-create-error/64423/1 "2016-10-31T09:55:56Z")

</div>

Hello everybody,

First of all my setup:

- ES 5 (upgraded from 2.4)
- My node.js app is accessing ES using the JavaScript API
- documents IDs are autogenerated by elastic

When running ES 2.4 issuing a `create` call such as:

```auto
client.create({
  index: 'myindex',
  type: 'mytype',
  body: {
    title: 'Test 1',
    tags: ['y', 'z'],
    published: true,
    published_at: '2013-01-01',
    counter: 1
  }
}, function (error, response) {
  // ...
});

```

would result, as expected, in the creation of a document.

Now, with ES 5.0, the same call results in this error:

```auto
{ "error": { "root_cause": [
    { 
      "type":"action_request_validation_exception",
      "reason":"Validation Failed: 1: an id must be provided if version type or value are set;"
    }
  ],
  "type":"action_request_validation_exception",
  "reason":"Validation Failed: 1: an id must be provided if version type or value are set;"},
  "status":400
}

```

The javascript call gets 'translated' into this REST call:

```auto
POST localhost:9200/examples/example?op_type=create
{
  index: 'myindex',
  type: 'mytype',
  body: {
    title: 'Test 1',
    tags: ['y', 'z'],
    published: true,
    published_at: '2013-01-01',
    counter: 1
  }
}

```

If I remove the `op_type=create` then everything is fine (note that in ES 2.4 the exact same REST call would result in the document being indexed, no problems)

I did not find anything in **breaking changes** mentioning something about the create API, but maybe I did not look hard enough into it.

Has anyone ran into this problem or can give me a hint or two how to solve this?

Thanks

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [October 31, 2016, 12:54pm UTC](https://discuss.elastic.co/t/es-5-0-op-type-create-error/64423/2 "2016-10-31T12:54:59Z")

</div>

You have to specify `id` in 5.0 when using op\_type=create. You can find the breaking changes doc for this at [https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking\_50\_index\_apis.html#\_optype\_create\_without\_an\_id](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_index_apis.html#_optype_create_without_an_id)

---

<div class="post-metadata">

**Author:** ![Bobo\_the\_Monkey](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@Bobo\_the\_Monkey](https://discuss.elastic.co/u/Bobo_the_Monkey)\
**Post date:** [October 31, 2016, 1:56pm UTC](https://discuss.elastic.co/t/es-5-0-op-type-create-error/64423/3 "2016-10-31T13:56:54Z")

</div>

Thank you @shanec, but I was trying to understand why the javascript library stopped working and probably I wasn't clear enough.

I do not directly set `op_type=create`, the library does it and obviously, now, I need to specify an ID while before I did not.

Fortunately, I can use [index](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-index) instead of [create](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-create). Then, the ID is autogenerated as before.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:08pm UTC](https://discuss.elastic.co/t/es-5-0-op-type-create-error/64423/4 "2017-07-05T22:08:17Z")

</div>


