# Updating a document with elasticsearch.js

**URL:** <https://discuss.elastic.co/t/updating-a-document-with-elasticsearch-js/115960>\
**Category:** Elasticsearch\
**Created:** [January 18, 2018, 12:19am UTC](https://discuss.elastic.co/t/updating-a-document-with-elasticsearch-js/115960 "2018-01-18T00:19:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradley](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@bradley](https://discuss.elastic.co/u/bradley)\
**Post date:** [January 18, 2018, 12:19am UTC](https://discuss.elastic.co/t/updating-a-document-with-elasticsearch-js/115960/1 "2018-01-18T00:19:58Z")

</div>

I'm trying to update a document with elasticsearch.js, and I'm getting a few errors from it. Here's what I'm using:

```
this.elasticClient.update({
  index: 'applicants',
  type: 'applicant',
  id: this.applicantId,
  body: {
    // put the partial document under the `doc` key
    doc: {test: 'test'}
  }
}, function (error, response) {
  console.warn(error, response);
});

```

That gives me:

```
error:
index: "applicants"
index_uuid: "hqhlmVWiRYSjby41ee8kyQ"
reason: "[applicant][Bt4r4WABRQSteENiaQRT]: document missing"
root_cause: [{…}]
shard: "0"
type: "document_missing_exception"
status: 404

```

The documentation seems a little vague, and I can't find a working example of how to use this.

---

<div class="post-metadata">

**Author:** ![bradley](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@bradley](https://discuss.elastic.co/u/bradley)\
**Post date:** [January 18, 2018, 1:45am UTC](https://discuss.elastic.co/t/updating-a-document-with-elasticsearch-js/115960/2 "2018-01-18T01:45:15Z")

</div>

Nevermind. I was using the wrong type. Used 'applicant'. Should have used 'doc'.

---

<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:** [February 15, 2018, 1:45am UTC](https://discuss.elastic.co/t/updating-a-document-with-elasticsearch-js/115960/3 "2018-02-15T01:45:41Z")

</div>

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