{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch-js/issues/731","repository_url":"https://api.github.com/repos/elastic/elasticsearch-js","labels_url":"https://api.github.com/repos/elastic/elasticsearch-js/issues/731/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch-js/issues/731/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch-js/issues/731/events","html_url":"https://github.com/elastic/elasticsearch-js/issues/731","id":382173795,"node_id":"MDU6SXNzdWUzODIxNzM3OTU=","number":731,"title":"Bulk actions for Index and Update: index or update with doc_as_upsert?","user":{"login":"loretoparisi","id":163333,"node_id":"MDQ6VXNlcjE2MzMzMw==","avatar_url":"https://avatars3.githubusercontent.com/u/163333?v=4","gravatar_id":"","url":"https://api.github.com/users/loretoparisi","html_url":"https://github.com/loretoparisi","followers_url":"https://api.github.com/users/loretoparisi/followers","following_url":"https://api.github.com/users/loretoparisi/following{/other_user}","gists_url":"https://api.github.com/users/loretoparisi/gists{/gist_id}","starred_url":"https://api.github.com/users/loretoparisi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loretoparisi/subscriptions","organizations_url":"https://api.github.com/users/loretoparisi/orgs","repos_url":"https://api.github.com/users/loretoparisi/repos","events_url":"https://api.github.com/users/loretoparisi/events{/privacy}","received_events_url":"https://api.github.com/users/loretoparisi/received_events","type":"User","site_admin":false},"labels":[{"id":1043919385,"node_id":"MDU6TGFiZWwxMDQzOTE5Mzg1","url":"https://api.github.com/repos/elastic/elasticsearch-js/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-19T11:34:00Z","updated_at":"2018-11-19T13:57:44Z","closed_at":"2018-11-19T13:12:17Z","author_association":"NONE","body":"I'm doing a index / update bulk call using the `client.bulk` api:\r\n\r\nWhen I do the `insert` action\r\n\r\n```javascript\r\n{\r\n                index: 'myIndex',\r\n                type: '_doc',\r\n                body: [\r\n                    // action description\r\n                    { index: { _id: docIDOne } },\r\n                    // the document to index\r\n                    itemOne,\r\n                    // action description\r\n                    { index: { _id: docIDTwo } },\r\n                    // the document to index\r\n                    itemTwo,\r\n                ]\r\n            }\r\n```\r\n\r\nThe index action works ok. At second attempt of the `index` action with the same items it works as well and I get a `updated` value for the `result` field in the response: \r\n\r\n```\r\n{\r\n      \"index\": {\r\n        \"_index\": \"entities\",\r\n        \"_type\": \"_doc\",\r\n        \"_id\": \"TGVCcm9u\",\r\n        \"_version\": 4,\r\n        \"result\": \"updated\",\r\n        \"_shards\": {\r\n          \"total\": 2,\r\n          \"successful\": 2,\r\n          \"failed\": 0\r\n        },\r\n        \"_seq_no\": 5,\r\n        \"_primary_term\": 1,\r\n        \"status\": 200\r\n      }\r\n```\r\n\r\nDoes this mean that that doc has been updated?\r\nI have tried also to use the `update` action with the `doc_as_upsert` flag like:\r\n\r\n```javascript\r\nelastic.bulk({\r\n                index: indexName,\r\n                type: '_doc',\r\n                body: [\r\n                    // action description\r\n                    { update: { _id: docIDOne } },\r\n                    // the document to index\r\n                    { doc_as_upsert : true, doc: itemOne },\r\n                    // action description\r\n                    { update: { _id: docIDTwo } },\r\n                    // the document to index\r\n                    { doc_as_upsert : true, doc: \r\n },\r\n                ]\r\n            });\r\n```\r\n\r\nand it gives me back a `created` result the first attempt, and a `noop` the second one. I suppose I will get a `updated` if it updates the content.\r\n\r\nSo the point is: which api call shall I use to perform something closer to a insert OR update: `index` or `update` with the `doc_as_upsert` flag?"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch-js/issues/comments/439901064","html_url":"https://github.com/elastic/elasticsearch-js/issues/731#issuecomment-439901064","issue_url":"https://api.github.com/repos/elastic/elasticsearch-js/issues/731","id":439901064,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTkwMTA2NA==","user":{"login":"delvedor","id":4865608,"node_id":"MDQ6VXNlcjQ4NjU2MDg=","avatar_url":"https://avatars0.githubusercontent.com/u/4865608?v=4","gravatar_id":"","url":"https://api.github.com/users/delvedor","html_url":"https://github.com/delvedor","followers_url":"https://api.github.com/users/delvedor/followers","following_url":"https://api.github.com/users/delvedor/following{/other_user}","gists_url":"https://api.github.com/users/delvedor/gists{/gist_id}","starred_url":"https://api.github.com/users/delvedor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delvedor/subscriptions","organizations_url":"https://api.github.com/users/delvedor/orgs","repos_url":"https://api.github.com/users/delvedor/repos","events_url":"https://api.github.com/users/delvedor/events{/privacy}","received_events_url":"https://api.github.com/users/delvedor/received_events","type":"User","site_admin":false},"created_at":"2018-11-19T13:57:44Z","updated_at":"2018-11-19T13:57:44Z","author_association":"MEMBER","body":"It's not documented because only querystring parameters are documented, all supported body keys are described in https://www.elastic.co/guide/en/elasticsearch/reference/6.5/docs-update.html (you can arrive at that URL from the js docs in the body section) ;)"}}
{"actor":{"display_login":"delvedor"}}