Bulk Load

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:

	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?

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