-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2b7b43
commit 90158a8
Showing
2 changed files
with
116 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,84 @@ | ||
<?php | ||
/** | ||
* User: zach | ||
* Date: 05/31/2013 | ||
* Time: 16:47:11 pm | ||
*/ | ||
|
||
namespace Elasticsearch\Endpoints; | ||
|
||
use Elasticsearch\Endpoints\AbstractEndpoint; | ||
use Elasticsearch\Common\Exceptions; | ||
use Elasticsearch\Serializers\SerializerInterface; | ||
use Elasticsearch\Transport; | ||
|
||
/** | ||
* Class MPercolate | ||
* @package Elasticsearch\Endpoints | ||
*/ | ||
class MPercolate extends AbstractEndpoint implements BulkEndpointInterface | ||
{ | ||
|
||
/** | ||
* @param Transport $transport | ||
* @param SerializerInterface $serializer | ||
*/ | ||
public function __construct(Transport $transport, SerializerInterface $serializer) | ||
{ | ||
$this->serializer = $serializer; | ||
parent::__construct($transport); | ||
} | ||
|
||
|
||
/** | ||
* @param string|array $body | ||
* | ||
* @return $this | ||
*/ | ||
public function setBody($body) | ||
{ | ||
if (isset($body) !== true) { | ||
return $this; | ||
} | ||
|
||
if (is_array($body) === true) { | ||
$bulkBody = ""; | ||
foreach ($body as $item) { | ||
$bulkBody .= $this->serializer->serialize($item)."\n"; | ||
} | ||
$body = $bulkBody; | ||
} | ||
|
||
$this->body = $body; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getURI() | ||
{ | ||
return $this->getOptionalURI('_mpercolate'); | ||
|
||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getParamWhitelist() | ||
{ | ||
return array( | ||
'ignore_unavailable', | ||
'allow_no_indices', | ||
'expand_wildcards', | ||
); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getMethod() | ||
{ | ||
return 'POST'; | ||
} | ||
} |