Commit 8e87e895 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "elasticsearch: Add index name to _bulk command path"

parents dbdeb077 278889b5
...@@ -8,4 +8,6 @@ This library is used for for interfacing with an elasticsearch server. ...@@ -8,4 +8,6 @@ This library is used for for interfacing with an elasticsearch server.
Changes: Changes:
* Removed build & test files not needed for Mahara. * Removed build & test files not needed for Mahara.
\ No newline at end of file * Added an option to do include the Elasticsearch Index in the URL for bulk addDocument calls
\ No newline at end of file
...@@ -291,15 +291,19 @@ class Client ...@@ -291,15 +291,19 @@ class Client
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
* *
* @param array|\Elastica\Document[] $docs Array of Elastica\Document * @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param string|\Elastica\Index (Optional) If all of the documents are for the same index
* @return \Elastica\Bulk\ResponseSet Response object * @return \Elastica\Bulk\ResponseSet Response object
*/ */
public function addDocuments(array $docs) public function addDocuments(array $docs, Index $index = null)
{ {
if (empty($docs)) { if (empty($docs)) {
throw new InvalidException('Array has to consist of at least one element'); throw new InvalidException('Array has to consist of at least one element');
} }
$bulk = new Bulk($this); $bulk = new Bulk($this);
if ($index) {
$bulk->setIndex($index);
}
$bulk->addDocuments($docs); $bulk->addDocuments($docs);
......
...@@ -145,7 +145,7 @@ class Index implements SearchableInterface ...@@ -145,7 +145,7 @@ class Index implements SearchableInterface
$doc->setIndex($this->getName()); $doc->setIndex($this->getName());
} }
return $this->getClient()->addDocuments($docs); return $this->getClient()->addDocuments($docs, $this);
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment