11

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?

1 Answer 1

17

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);
Sign up to request clarification or add additional context in comments.

2 Comments

still works, i'm using elasticsearch 2.3! thank you!
Thanks, feel free to upvote the question and all that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.