nervetattoo/elasticsearch — pull request #44 by jclg (2014-07-21 13:37:28+00:00)
Title: Missing ending newline in bulk payload

Hi,

It seems an ending newline is needed when creating the bulk payload (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html).

For example, when I index three documents with the bulk api, the last document is not indexed :

```
'My bulked entry 1');
$documents['doc2'] = array('title' => 'My bulked entry 2');
$documents['doc3'] = array('title' => 'My bulked entry 3');

$es->beginBulk();
foreach ($documents as $id => $document) {
echo "Indexing document $id\n";
$es->index($document, $id);
}
$es->commitBulk();
```

Only the first two documents are indexed :

curl -XGET 'http://127.0.0.1:9200/myindex/mytype/_search?pretty=true'

```
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "myindex",
"_type" : "mytype",
"_id" : "doc1",
"_score" : 1.0, "_source" : {"title":"My bulked entry 1"}
}, {
"_index" : "myindex",
"_type" : "mytype",
"_id" : "doc2",
"_score" : 1.0, "_source" : {"title":"My bulked entry 2"}
} ]
}
}
```

Expected result :
```
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 3,
"max_score" : 1.0,
"hits" : [ {
"_index" : "myindex",
"_type" : "mytype",
"_id" : "doc1",
"_score" : 1.0, "_source" : {"title":"My bulked entry 1"}
}, {
"_index" : "myindex",
"_type" : "mytype",
"_id" : "doc2",
"_score" : 1.0, "_source" : {"title":"My bulked entry 2"}
}, {
"_index" : "myindex",
"_type" : "mytype",
"_id" : "doc3",
"_score" : 1.0, "_source" : {"title":"My bulked entry 3"}
} ]
}
}
```