bulk using curl and php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat a.php | |
<?php | |
$cmd = "curl -XPUT http://localhost:9200/_bulk --data-binary @bulkIndex.data"; | |
exec($cmd); | |
?> | |
$ 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"} | |
$ curl -XDELETE localhost:9200/test | |
{"ok":true,"acknowledged":true} | |
$ php a.php | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
100 1125 100 248 100 877 895 3167 --:--:-- --:--:-- --:--:-- 3177 | |
$ curl localhost:9200/test/_search?pretty=true | |
{ | |
"took" : 3, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 1, | |
"successful" : 1, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 3, | |
"max_score" : 1.0, | |
"hits" : [ { | |
"_index" : "test", | |
"_type" : "mo", | |
"_id" : "1", | |
"_score" : 1.0, "_source" : {"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" : "test", | |
"_type" : "mo", | |
"_id" : "2", | |
"_score" : 1.0, "_source" : {"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" : "test", | |
"_type" : "mt", | |
"_id" : "32030", | |
"_score" : 1.0, "_source" : {"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"} | |
} ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment