Bulk index "Failed to derive xcontent" error

Hi all! I'm still fairly new to elasticsearch. So far so good until I am
now attempting to use the bulk index API.

I have a PHP script pulling data from an Oracle db, creating a
'bulkIndex.data' file, and I'm trying to index it using:

$cmd = "curl -XPUT http://localhost:9200/_bulk --data-binary
@bulkIndex.data";
exec($cmd);

I'm getting an error:

{"error":"Failed to derive xcontent from org.elasticsearch.common.bytes.ChannelBufferBytesReference@77256a74"}

Here is a sample of the contents of my file:

$ cat bulkIndex.data
{ "index" : {"_index":"test","_type":"mo","_id":"1"} }
{"CDR_ID":"4894","MSISDN":"14169988312","SHORT_CODE":"44446","APP_ID":"1158","OPERATOR_ID":"0","SHORT_MESSAGE":"Test1","SMS_ID":"19f1eb3d1b5579781ba1c051d8d6739e","DATE_TIMESTAMP":"20120727131710","INSERT_TIMESTAMP":"20121129212256"}
{ "index" : {"_index":"test","_type":"mo","_id":"2"} }
{"CDR_ID":"4895","MSISDN":"17059380753","SHORT_CODE":"41128","APP_ID":"1038","OPERATOR_ID":"0","SHORT_MESSAGE":"Test2","SMS_ID":"d8d849f760623f1720ef08634b3867b4","DATE_TIMESTAMP":"20120727131804","INSERT_TIMESTAMP":"20121129212256"}
...

{ "index" : {"_index":"test","_type":"mt","_id":"32030"} }
{"CDR_ID":"56163","MSISDN":"9026290583","SHORT_CODE":"41225","APP_ID":"1038","OPERATOR_ID":"0","SHORT_MESSAGE":"Test32030","SMS_ID":"67709e2f908c072112db7f1c173af0b9","DATE_TIMESTAMP":"20120731215731","INSERT_TIMESTAMP":"20121203172327"}

$

Why am I getting this error? Any help would be greatly appreciated. Thank
you!

--

Hello Doug,

That's strange, because it works for me, with the data you provided:

Can you share a script and an input file where the problem is reproducible?

Anyway, I think the way to go with PHP and Elasticsearch is by using the
Elastica[0] or Elasticsearch[1]. Although I've never used them, AFAIK at
least Elastica supports bulks. So you can write docs directly, without
needing to write them to a file.

Another cool thing that might fit your usecase is the JDBC river[2]. This
would enable Elasticsearch to automatically pull data from your DB.

[0] https://github.com/ruflin/Elastica
[1] https://github.com/nervetattoo/elasticsearch
[2] https://github.com/jprante/elasticsearch-river-jdbc

Best regards,
Radu

http://sematext.com/ -- ElasticSearch -- Solr -- Lucene

On Mon, Dec 3, 2012 at 11:04 PM, Doug Richar drichar@gmail.com wrote:

Hi all! I'm still fairly new to elasticsearch. So far so good until I am
now attempting to use the bulk index API.

I have a PHP script pulling data from an Oracle db, creating a
'bulkIndex.data' file, and I'm trying to index it using:

$cmd = "curl -XPUT http://localhost:9200/_bulk --data-binary
@bulkIndex.data";
exec($cmd);

I'm getting an error:

{"error":"Failed to derive xcontent from org.elasticsearch.common.bytes.ChannelBufferBytesReference@77256a74"}

Here is a sample of the contents of my file:

$ cat bulkIndex.data
{ "index" : {"_index":"test","_type":"mo","_id":"1"} }
{"CDR_ID":"4894","MSISDN":"14169988312","SHORT_CODE":"44446","APP_ID":"1158","OPERATOR_ID":"0","SHORT_MESSAGE":"Test1","SMS_ID":"19f1eb3d1b5579781ba1c051d8d6739e","DATE_TIMESTAMP":"20120727131710","INSERT_TIMESTAMP":"20121129212256"}
{ "index" : {"_index":"test","_type":"mo","_id":"2"} }
{"CDR_ID":"4895","MSISDN":"17059380753","SHORT_CODE":"41128","APP_ID":"1038","OPERATOR_ID":"0","SHORT_MESSAGE":"Test2","SMS_ID":"d8d849f760623f1720ef08634b3867b4","DATE_TIMESTAMP":"20120727131804","INSERT_TIMESTAMP":"20121129212256"}
...

{ "index" : {"_index":"test","_type":"mt","_id":"32030"} }
{"CDR_ID":"56163","MSISDN":"9026290583","SHORT_CODE":"41225","APP_ID":"1038","OPERATOR_ID":"0","SHORT_MESSAGE":"Test32030","SMS_ID":"67709e2f908c072112db7f1c173af0b9","DATE_TIMESTAMP":"20120731215731","INSERT_TIMESTAMP":"20121203172327"}

$

Why am I getting this error? Any help would be greatly appreciated. Thank
you!

--

--