# Bulk Load

**URL:** <https://discuss.elastic.co/t/bulk-load/140536>\
**Category:** Elasticsearch\
**Created:** [July 18, 2018, 11:54am UTC](https://discuss.elastic.co/t/bulk-load/140536 "2018-07-18T11:54:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LesioS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lesios/32/32364_2.png) [@LesioS](https://discuss.elastic.co/u/LesioS)\
**Post date:** [July 18, 2018, 11:54am UTC](https://discuss.elastic.co/t/bulk-load/140536/1 "2018-07-18T11:54:37Z")

</div>

Sorry in advance, if it's wrong place, but I haven't found better.

I've app written in Go where I try to make bulk load to ES. My code looks similar to:

```auto
	url := c.url + "/" + sess.SessionIndexName + "/sess/_bulk"

	idrow := IdRow{
		Index: Index{
			Index: sess.SessionIndexName,
			ID: sess.SessionID,
		},
	}

	sessionDoc, err := ffjson.Marshal(sess.SessionDoc)
	if err != nil {
		// error queue
		return
	}
	idx, err := ffjson.Marshal(idrow)
	if err != nil {
		// error queue
		return
	}

	body += fmt.Sprintf("%s\n", idx)
	body += fmt.Sprintf("%s\n", sessionDoc)

	req, err := http.NewRequest("POST",	url, bytes.NewBufferString(body))
	auth := base64.StdEncoding.EncodeToString([]byte(c.login + ":" + c.password))
	req.Header.Add("Authorization","Basic " + auth)

	req.Header.Set("Content-Type", "application/x-ndjson")

	resp, err := c.client.Do(req)
	if err != nil {
		// error queue
		return
	}
	defer resp.Body.Close()

```

`sess.SessionIndexName` contains `session` which comes from mapping:  
`PUT session { "mappings": { "sess": { "properties": {...`

Final call is here:  
`resp, err := c.client.Do(req) if err != nil {...`

err return null, which means that everything is OK. resp in header has code '200 OK' which also states success.  
But there's no success: doc is not visible under Dev Tool in Kibana. Call `GET session/_search` always returns:  
`{ "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 0, "max_score": null, "hits": [] } }`

Calling `curl --user xxx:yyy --insecure -H "Content-Type: application/x-ndjson" -XPOST https://localhost:9200/session/sess/_bulk?pretty --data-binary @test.json` with doc in test.json file loads data properly to ES.

Any tips what's wrong?

---

<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:** [August 15, 2018, 11:54am UTC](https://discuss.elastic.co/t/bulk-load/140536/2 "2018-08-15T11:54:37Z")

</div>

Closed on August 15, 2018, 11:54am UTC

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