简体   繁体   中英

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM