diff --git a/htdocs/lib/elastica/README.Mahara b/htdocs/lib/elastica/README.Mahara index 2e6c455ebb963a81b5a0b7bd704c43745fdd6202..ac559455cc26bd45cd927caf43befe0b70a3bb0d 100644 --- a/htdocs/lib/elastica/README.Mahara +++ b/htdocs/lib/elastica/README.Mahara @@ -8,4 +8,6 @@ This library is used for for interfacing with an elasticsearch server. Changes: - * Removed build & test files not needed for Mahara. \ No newline at end of file + * Removed build & test files not needed for Mahara. + * Added an option to do include the Elasticsearch Index in the URL for bulk addDocument calls + \ No newline at end of file diff --git a/htdocs/lib/elastica/lib/Elastica/Client.php b/htdocs/lib/elastica/lib/Elastica/Client.php index c5e56885cffde78b891d6b3f5c9cf1e15f363dca..55c39435a41539bfe0136b6be4692c1785df5e40 100644 --- a/htdocs/lib/elastica/lib/Elastica/Client.php +++ b/htdocs/lib/elastica/lib/Elastica/Client.php @@ -291,15 +291,19 @@ class Client * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html * * @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 */ - public function addDocuments(array $docs) + public function addDocuments(array $docs, Index $index = null) { if (empty($docs)) { throw new InvalidException('Array has to consist of at least one element'); } $bulk = new Bulk($this); + if ($index) { + $bulk->setIndex($index); + } $bulk->addDocuments($docs); diff --git a/htdocs/lib/elastica/lib/Elastica/Index.php b/htdocs/lib/elastica/lib/Elastica/Index.php index 1d2a78fddd5fbabb349fbc3e372c10552d16296f..b8f1abfe0394e5169cf2a1ac77f7e764221f117b 100644 --- a/htdocs/lib/elastica/lib/Elastica/Index.php +++ b/htdocs/lib/elastica/lib/Elastica/Index.php @@ -145,7 +145,7 @@ class Index implements SearchableInterface $doc->setIndex($this->getName()); } - return $this->getClient()->addDocuments($docs); + return $this->getClient()->addDocuments($docs, $this); } /**