Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Params passed to Client through Index and Type #1427

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file based on the
### Added

* Added request parameters to `Client->deleteDocuments()`. [#1419](https://github.com/ruflin/Elastica/pull/1419)
* Added request parameters to `Type->updateDocuments()`, `Type->addDocuments()`, `Type->addObjects()`, `Index->addDocuments()`, `Index->updateDocuments()`. [#1427](https://github.com/ruflin/Elastica/pull/1427)

### Improvements

Expand Down
10 changes: 6 additions & 4 deletions lib/Elastica/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,38 @@ public function getSettings()
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function updateDocuments(array $docs)
public function updateDocuments(array $docs, array $options = [])
{
foreach ($docs as $doc) {
$doc->setIndex($this->getName());
}

return $this->getClient()->updateDocuments($docs);
return $this->getClient()->updateDocuments($docs, $options);
}

/**
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function addDocuments(array $docs)
public function addDocuments(array $docs, array $options = [])
{
foreach ($docs as $doc) {
$doc->setIndex($this->getName());
}

return $this->getClient()->addDocuments($docs);
return $this->getClient()->addDocuments($docs, $options);
}

/**
Expand Down
19 changes: 10 additions & 9 deletions lib/Elastica/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,48 +167,49 @@ public function updateDocument($data, array $options = [])
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function updateDocuments(array $docs)
public function updateDocuments(array $docs, array $options = [])
{
foreach ($docs as $doc) {
$doc->setType($this->getName());
}

return $this->getIndex()->updateDocuments($docs);
return $this->getIndex()->updateDocuments($docs, $options);
}

/**
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
*
* @param array $options Array of query params to use for query. For possible options check es api
* @return \Elastica\Bulk\ResponseSet
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function addDocuments(array $docs)
public function addDocuments(array $docs, array $options = [])
{
foreach ($docs as $doc) {
$doc->setType($this->getName());
}

return $this->getIndex()->addDocuments($docs);
return $this->getIndex()->addDocuments($docs, $options);
}

/**
* Uses _bulk to send documents to the server.
*
* @param objects[] $objects
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
*
* @return Bulk\ResponseSet
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function addObjects(array $objects)
public function addObjects(array $objects, array $options = [])
{
if (!isset($this->_serializer)) {
throw new RuntimeException('No serializer defined');
Expand All @@ -223,7 +224,7 @@ public function addObjects(array $objects)
$docs[] = $doc;
}

return $this->getIndex()->addDocuments($docs);
return $this->getIndex()->addDocuments($docs, $options);
}

/**
Expand Down