以下是向批量发送请求的子例程 它将输入作为json并输出结果
sub BulkJSON(){
my $json=@_[1];
#$id = lc $id; # Convert to lowercase as Elastic doesn't support uppercase ids
my $uri = $base_url.'/_bulk';
my $req = HTTP::Request->new( 'POST', $uri );
$req->header( 'Content-Type' => 'application/json' );
$req->content($json);
my $browser = LWP::UserAgent->new;
my $response = $browser->request($req);
$html = $response->content()."\n";
return "$html";
}