DocumentMissingException on bulk upsert

Hi All,
I am using ES 1.7
also am using Python client for some particular type of data.

I need very small document to index
{
date : ....
count: 1000
}

every document will have some predefined id
so below is the upsert command i am using (es python helper bulk)

{"_id": "clientk1113120160208172000", "_op_type": "update", "_type": "Count", "doc": {"script": "ctx._source.counter +=16", "upsert": {"counter": 16, "fdate": "2016-02-08T17:20:00"}}}

but its giving me below error

'1 document(s) failed to index.'
[{
u'update': {
u'status': 404,
u'_type': u'Count',
u'_id': u'clientk1113120160208122000',
u'error': u'DocumentMissingException[[clientk1113-rawlog-write][-1][Count][clientk1113120160208122000]: documentmissing]',
u'_index': u'clientk1113-rawlog-write'
}
}]

any help will be appreciated

Thanks

One thing I noticed is that the document ID of your request does not match the document ID mentioned in your error response.

Second, for the upsert request, there is no outer "doc" element, see this example for how to formulate the JSON: https://www.elastic.co/guide/en/elasticsearch/reference/2.0/docs-update.html#upserts

1 Like

yes it worked!
{"_op_type":"update","_type":"Count","_id":"clientk1113120160122095000","script":"ctx._source.counter +=18802","upsert":{"counter":18802,"fdate":"2016-01-22T09:50:00"}}