Commit 3c7e24e7 authored by Aaron Wells's avatar Aaron Wells

elasticsearch: Add index name to _bulk command path

Bug 1457709: We only do this when the command comes
from an Index object itself, which means that all the
data in the bulk request will have the same index anyway.

You'll still need to set rest.action.multi.allow_explicit_index:false
in your config.yml, or else the data will be able to override the
index name in the URL.



behatnotneeded: Can't be tested in behat

Change-Id: Ide22a0026aeb480a130e39c3ea2f327ef2de167f
parent b47734b0
......@@ -12,3 +12,5 @@ Dependencies:
* Removed build & test files not needed for Mahara.
* Added an option to do include the Elasticsearch Index in the URL for bulk addDocument calls
......@@ -295,19 +295,23 @@ class Client
* @link
* @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
* @throws \Elastica\Exception\InvalidException If docs is empty
* @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) {
......@@ -147,7 +147,7 @@ class Index implements SearchableInterface
return $this->getClient()->addDocuments($docs);
return $this->getClient()->addDocuments($docs, $this);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment