-
Notifications
You must be signed in to change notification settings - Fork 980
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-Add the DeleteByQuery Functionality (#513)
* Re-Add the DeleteByQuery Functionality Reverts 9f3776a and brings the `DeleteByQuery` endpoint up to spec with the current API. * Remove `slice` as a Parameter from DeleteByQuery It's in the request body, not the query string. * Include All the DeleteByQuery Params Generated from a bit of scripting around the delete by query api spec.
- Loading branch information
1 parent
f32cc54
commit b262dca
Showing
2 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
namespace Elasticsearch\Endpoints; | ||
|
||
use Elasticsearch\Common\Exceptions; | ||
|
||
/** | ||
* Class Deletebyquery | ||
* | ||
* @category Elasticsearch | ||
* @package Elasticsearch\Endpoints | ||
* @author Zachary Tong <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elastic.co | ||
*/ | ||
class DeleteByQuery extends AbstractEndpoint | ||
{ | ||
/** | ||
* @param array $body | ||
* | ||
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException | ||
* @return $this | ||
*/ | ||
public function setBody($body) | ||
{ | ||
if (isset($body) !== true) { | ||
return $this; | ||
} | ||
|
||
$this->body = $body; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @throws \Elasticsearch\Common\Exceptions\RuntimeException | ||
* @return string | ||
*/ | ||
protected function getURI() | ||
{ | ||
if (!$this->index) { | ||
throw new Exceptions\RuntimeException( | ||
'index is required for Deletebyquery' | ||
); | ||
} | ||
|
||
$uri = "/{$this->index}/_delete_by_query"; | ||
if ($this->type) { | ||
$uri = "/{$this->index}/{$this->type}/_delete_by_query"; | ||
} | ||
|
||
return $uri; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getParamWhitelist() | ||
{ | ||
return array( | ||
'_source', | ||
'_source_exclude', | ||
'_source_include', | ||
'allow_no_indices', | ||
'analyze_wildcard', | ||
'analyzer', | ||
'conflicts', | ||
'default_operator', | ||
'df', | ||
'expand_wildcards', | ||
'from', | ||
'ignore_unavailable', | ||
'lenient', | ||
'preference', | ||
'q', | ||
'refresh', | ||
'request_cache', | ||
'requests_per_second', | ||
'routing', | ||
'scroll', | ||
'scroll_size', | ||
'search_timeout', | ||
'search_type', | ||
'size', | ||
'slices', | ||
'sort', | ||
'stats', | ||
'terminate_after', | ||
'timeout', | ||
'version', | ||
'wait_for_active_shards', | ||
'wait_for_completion', | ||
); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getMethod() | ||
{ | ||
return 'POST'; | ||
} | ||
} |