Skip to content

Commit

Permalink
Allow for request params in delete by query calls
Browse files Browse the repository at this point in the history
Delete by query calls allows for optional request params to tune things
like routing, replication and consistency.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete-by-query.html#delete-by-query-parameters
  • Loading branch information
xyu committed Mar 20, 2014
1 parent bf88476 commit d170d90
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Elastica/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,21 @@ public function deleteIds(array $ids)
/**
* Deletes entries in the db based on a query
*
* @param \Elastica\Query|string $query Query object
* @param \Elastica\Query|string $query Query object
* @param array $options Optional params
* @return \Elastica\Response
* @link http://www.elasticsearch.org/guide/reference/api/delete-by-query.html
*/
public function deleteByQuery($query)
public function deleteByQuery($query, array $options = array())
{
if (is_string($query)) {
// query_string queries are not supported for delete by query operations
return $this->request('_query', Request::DELETE, array(), array('q' => $query));
$options['q'] = $query;
return $this->request('_query', Request::DELETE, array(), $options);
}
$query = Query::create($query);

return $this->request('_query', Request::DELETE, array('query' => $query->getQuery()));
return $this->request('_query', Request::DELETE, array('query' => $query->getQuery()), $options);
}

/**
Expand Down

0 comments on commit d170d90

Please sign in to comment.