Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do bulk delete in PHP ElasticSearch API

How to do bulk delete in PHP ElasticSearch API? I know that there are issues with delete by query princip, so I want to try the bulk delete function, but I don't know how to use it. So, I want to know how to use the $client -> bulk method of the ElasticSearch PHP API. Anyone?

like image 203
Vladimir Despotovic Avatar asked Jan 29 '16 16:01

Vladimir Despotovic


1 Answers

Turns out it is very simple:

for ($i = 303; $i < 310; $i++) {  
    $params ['body'][] = array(  
        'delete' => array(  
            '_index' => 'er',  
            '_type' => 'state',  
            '_id' => $i  
        )  
    );  
}  
$response = $client -> bulk($params);
like image 176
Vladimir Despotovic Avatar answered Oct 21 '22 06:10

Vladimir Despotovic