Commit 87d79be9 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review

Merge changes from topic 'elastica upgrade'

* changes:
  elasticsearch: Add index name to _bulk command path
  Bug #1613478: Update Elastica library to 2.3.1
parents 8e99d291 3c7e24e7
This diff is collapsed.
Contributing
============
Help is very welcomed. Code contributions must be done in respect of [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).
More details on how to contribute and guidelines for [pull requests](http://elastica.io/contribute/pull-request.html) can be found [here](http://elastica.io/contribute/).
See [Coding guidelines](http://elastica.io/contribute/coding-guidelines.html) for tips on how to do so.
All changes must be documented in the [CHANGELOG.md](https://github.com/ruflin/Elastica/blob/master/CHANGELOG.md).
Issues
------
* Bugs & Feature requests: If you found a bug, open an issue on [Github](https://github.com/ruflin/Elastica/issues). Please search for already reported similary issues before opening a new one. You should include code examples (with dependencies if needed) and your Elastica version to the issue description.
* Questions & Problems: If you have questions or a specific problem, use the [Elastica Gitter](https://gitter.im/ruflin/Elastica) Chat or open an issue on [Stackoverflow](http://stackoverflow.com/questions/tagged/elastica). Make sure to assign the tag Elastica.
Setup
-----
Elastica currently allows two setups for development. Either through vagrant or docker-compose. To use the vagrant environment, run `vagrant up`. To use the docker environment, check out the Makefile for the necessary commands.
* Run your changes / tests in the virtual environment to make sure it is reproducible.
* Run the tests before creating the pull request using vagrant or docker-compose locally.
Commands
--------
To run the commands below, you must have docker-compose [installed](https://docs.docker.com/compose/install/). The first time the commands are run it takes some time to download all the partial images. From then on the commands should run very fast. The advantage in using the commands below is that no local tools and libraries have to be installed and it is guaranteed that everytone is using the same tools.
## Run Tests
To run all tests inside the docker environment, run the following command:
```
make run RUN="make phpunit"
```
If you want to run just a specific test or a one specific file, run the following command by replacing your file with the existingpath:
```
make run RUN="phpunit -c ./test lib/Elastica/Test/SearchTest.php"
```
## Check style of your code
This command will call php-cs-fixer with the predefined settings for the elastica project. No local setup of the tools is needed as everything will happen directly in the container.
```
make run RUN="make lint"
```
Coding
------
### Rules
* Pull requests are made to master. Changes are never pushed directly (without pull request) into master.
* We use the Forking Workflow. https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow
* Follow the coding guidelines.
* Use a feature branch for every pull request. Don't open a pull request from your master branch.
### Pull Requests
* One change per pull requests: Keep your pull requests as small as possible. Only one change should happen per pull request. This makes it easier to review and provided feedback. If you have a large pull request, try to split it up in multiple smaller requests.
* Commit messages: Make sure that your commit messages have meaning and provide an understanding on what was changed without looking at the code.
* Pull requests should be opened as early as possible as pull requests are also here for communication / discussing changes. Add a comment when your pull request is ready to be merged.
* Tests: Your addition / change must be tested and the builds must be green. Test your changes locally. Add unit tests and if possible functional tests. Don't forget to add the group to your tests. The 4 available groups are @functional, @unit, @shutdown, @benchmark
* Update the CHANGELOG.md file with your changes
* Backward Compatibility breaks: In case you break backward compatibility, provide details on why this is needed.
* Merge: No one should ever merge his own pull request
### Name Spaces & Classes
Most name spaces and classes are self explanotary and use cases can be taken from classes which already exist.
#### Tool Namespace
The namespace Tool is used for making more complex functionality of Elastica available to the users. In general it maps existing functionality of Elastica and offers simplified functions.
#### Util Class
The util class is used for all static functions which are used in the Elastica library but don't access the library itself.
...@@ -2,12 +2,15 @@ Elastica in Mahara ...@@ -2,12 +2,15 @@ Elastica in Mahara
====================== ======================
Website: http://elastica.io Website: http://elastica.io
Version: 2.0.0 Version: 2.3.1
This library is used for for interfacing with an elasticsearch server. This library is used for for interfacing with an elasticsearch server.
Dependencies:
* Elasticsearch 1.7.3
Changes: Changes:
* Removed build & test files not needed for Mahara. * Removed build & test files not needed for Mahara.
* Added an option to do include the Elasticsearch Index in the URL for bulk addDocument calls * Added an option to do include the Elasticsearch Index in the URL for bulk addDocument calls
\ No newline at end of file
...@@ -3,28 +3,29 @@ Elastica: elasticsearch PHP Client ...@@ -3,28 +3,29 @@ Elastica: elasticsearch PHP Client
[![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable.png)](https://packagist.org/packages/ruflin/elastica) [![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable.png)](https://packagist.org/packages/ruflin/elastica)
[![Build Status](https://secure.travis-ci.org/ruflin/Elastica.png?branch=master)](http://travis-ci.org/ruflin/Elastica) [![Build Status](https://secure.travis-ci.org/ruflin/Elastica.png?branch=master)](http://travis-ci.org/ruflin/Elastica)
[![Coverage Status](https://coveralls.io/repos/ruflin/Elastica/badge.png)](https://coveralls.io/r/ruflin/Elastica) [![codecov.io](http://codecov.io/github/ruflin/Elastica/coverage.svg?branch=master)](http://codecov.io/github/ruflin/Elastica?branch=master)
[![Dependency Status](https://www.versioneye.com/php/ruflin:Elastica/master/badge.png)](https://www.versioneye.com/php/ruflin:elastica/) [![Dependency Status](https://www.versioneye.com/php/ruflin:elastica/dev-master/badge.svg)](https://www.versioneye.com/php/ruflin:elastica/dev-master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ruflin/Elastica/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ruflin/Elastica/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ruflin/Elastica/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ruflin/Elastica/?branch=master)
[![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads.png)](https://packagist.org/packages/ruflin/elastica) [![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads.png)](https://packagist.org/packages/ruflin/elastica)
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ruflin&url=https://github.com/ruflin/Elastica&title=Elastica&language=PHP&tags=github&category=software) [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ruflin&url=https://github.com/ruflin/Elastica&title=Elastica&language=PHP&tags=github&category=software)
[![Join the chat at https://gitter.im/ruflin/Elastica](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ruflin/Elastica?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
All documentation for Elastica can be found under [Elastica.io](http://Elastica.io/). If you have questions, don't hesitate to ask them in the [Elastica google group](https://groups.google.com/group/elastica-php-client). All library issues should go to the [issue tracker from github](https://github.com/ruflin/Elastica/issues). All documentation for Elastica can be found under [Elastica.io](http://Elastica.io/).
If you have questions, don't hesitate to ask them on [Stackoverflow](http://stackoverflow.com/questions/tagged/elastica) and add the Tag "Elastica" or
in our [Gitter](https://gitter.im/ruflin/Elastica) channel.
All library issues should go to the [issue tracker from github](https://github.com/ruflin/Elastica/issues).
Contributing Contributing
------------ ------------
Help is very welcomed, but code contributions must be done in respect of [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). More details on how to contribute and guidelines for [pull requests](http://elastica.io/contribute/pull-request.html) can be found [here](http://elastica.io/contribute/). Contributions are always welcome. For details on how to contribute, check the [CONTRIBUTING](https://github.com/ruflin/Elastica/blob/master/CONTRIBUTING.md) file.
See [Coding guidelines](http://elastica.io/contribute/coding-guidelines.html) for tips on how to do so. All changes which are made to the project are added to the [changes.txt](https://github.com/ruflin/Elastica/blob/master/changes.txt).
Dependencies Dependencies
------------ ------------
| Project | Version | Required | | Project | Version | Required |
|---------|---------|----------| |---------|---------|----------|
|[Elasticsearch](https://github.com/elasticsearch/elasticsearch/tree/v1.5.2)|1.5.2|yes| |[Elasticsearch](https://github.com/elasticsearch/elasticsearch/tree/v1.7.2)|1.7.2|yes|
|[Elasticsearch mapper attachments plugin](https://github.com/elasticsearch/elasticsearch-mapper-attachments/tree/v2.5.0)|2.5.0|no| |[Elasticsearch mapper attachments plugin](https://github.com/elasticsearch/elasticsearch-mapper-attachments/tree/v2.7.0)|2.7.0|no|
|[Elasticsearch thrift transport plugin](https://github.com/elasticsearch/elasticsearch-transport-thrift/tree/v2.5.0)|2.5.0|no| |[Elasticsearch thrift transport plugin](https://github.com/elasticsearch/elasticsearch-transport-thrift/tree/v2.7.0)|2.7.0|no|
|[Elasticsearch memcached transport plugin](https://github.com/elasticsearch/elasticsearch-transport-memcached/tree/v2.5.0)|2.5.0|no| |[Elasticsearch memcached transport plugin](https://github.com/elastic/elasticsearch-transport-memcached/tree/v2.7.0)|2.7.0|no|
|[Elasticsearch geocluster facet plugin](https://github.com/zenobase/geocluster-facet/tree/0.0.12)|0.0.12|no| |[Elasticsearch geocluster facet plugin](https://github.com/zenobase/geocluster-facet/tree/0.0.12)|0.0.12|no|
|[Elasticsearch image plugin](https://github.com/SibaTokyo/elasticsearch-image/tree/1.4.0)|1.4.0|no| |[Elasticsearch image plugin](https://github.com/Jmoati/elasticsearch-image/releases/tag/1.7.1)|1.7.1|no|
<?php
namespace Elastica;
/**
* Base class for Script object.
*
* @author Nicolas Assing <nicolas.assing@gmail.com>
*
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
*/
abstract class AbstractScript extends AbstractUpdateAction
{
/**
* @param array|null $params
* @param string $id
*/
public function __construct(array $params = null, $id = null)
{
if ($params) {
$this->setParams($params);
}
if ($id) {
$this->setId($id);
}
}
}
<?php <?php
namespace Elastica; namespace Elastica;
/** /**
* Base class for things that can be sent to the update api (Document and * Base class for things that can be sent to the update api (Document and
* Script). * Script).
* *
* @category Xodoa
* @package Elastica
* @author Nik Everett <nik9000@gmail.com> * @author Nik Everett <nik9000@gmail.com>
*/ */
class AbstractUpdateAction extends Param class AbstractUpdateAction extends Param
...@@ -20,7 +17,8 @@ class AbstractUpdateAction extends Param ...@@ -20,7 +17,8 @@ class AbstractUpdateAction extends Param
/** /**
* Sets the id of the document. * Sets the id of the document.
* *
* @param string $id * @param string $id
*
* @return $this * @return $this
*/ */
public function setId($id) public function setId($id)
...@@ -29,7 +27,7 @@ class AbstractUpdateAction extends Param ...@@ -29,7 +27,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Returns document id * Returns document id.
* *
* @return string|int Document id * @return string|int Document id
*/ */
...@@ -47,9 +45,10 @@ class AbstractUpdateAction extends Param ...@@ -47,9 +45,10 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Sets lifetime of document * Sets lifetime of document.
*
* @param string $ttl
* *
* @param string $ttl
* @return $this * @return $this
*/ */
public function setTtl($ttl) public function setTtl($ttl)
...@@ -74,9 +73,10 @@ class AbstractUpdateAction extends Param ...@@ -74,9 +73,10 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Sets the document type name * Sets the document type name.
*
* @param string $type Type name
* *
* @param string $type Type name
* @return $this * @return $this
*/ */
public function setType($type) public function setType($type)
...@@ -90,7 +90,7 @@ class AbstractUpdateAction extends Param ...@@ -90,7 +90,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Return document type name * Return document type name.
* *
* @throws \Elastica\Exception\InvalidException * @throws \Elastica\Exception\InvalidException
* *
...@@ -102,9 +102,10 @@ class AbstractUpdateAction extends Param ...@@ -102,9 +102,10 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Sets the document index name * Sets the document index name.
*
* @param string $index Index name
* *
* @param string $index Index name
* @return $this * @return $this
*/ */
public function setIndex($index) public function setIndex($index)
...@@ -117,7 +118,7 @@ class AbstractUpdateAction extends Param ...@@ -117,7 +118,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Get the document index name * Get the document index name.
* *
* @throws \Elastica\Exception\InvalidException * @throws \Elastica\Exception\InvalidException
* *
...@@ -129,10 +130,12 @@ class AbstractUpdateAction extends Param ...@@ -129,10 +130,12 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Sets the version of a document for use with optimistic concurrency control * Sets the version of a document for use with optimistic concurrency control.
*
* @param int $version Document version
* *
* @param int $version Document version
* @return $this * @return $this
*
* @link https://www.elastic.co/blog/versioning * @link https://www.elastic.co/blog/versioning
*/ */
public function setVersion($version) public function setVersion($version)
...@@ -141,7 +144,7 @@ class AbstractUpdateAction extends Param ...@@ -141,7 +144,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Returns document version * Returns document version.
* *
* @return string|int Document version * @return string|int Document version
*/ */
...@@ -160,9 +163,10 @@ class AbstractUpdateAction extends Param ...@@ -160,9 +163,10 @@ class AbstractUpdateAction extends Param
/** /**
* Sets the version_type of a document * Sets the version_type of a document
* Default in ES is internal, but you can set to external to use custom versioning * Default in ES is internal, but you can set to external to use custom versioning.
*
* @param int $versionType Document version type
* *
* @param int $versionType Document version type
* @return $this * @return $this
*/ */
public function setVersionType($versionType) public function setVersionType($versionType)
...@@ -171,7 +175,7 @@ class AbstractUpdateAction extends Param ...@@ -171,7 +175,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Returns document version type * Returns document version type.
* *
* @return string|int Document version type * @return string|int Document version type
*/ */
...@@ -189,10 +193,12 @@ class AbstractUpdateAction extends Param ...@@ -189,10 +193,12 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Sets parent document id * Sets parent document id.
*
* @param string|int $parent Parent document id
* *
* @param string|int $parent Parent document id
* @return $this * @return $this
*
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-parent-field.html * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-parent-field.html
*/ */
public function setParent($parent) public function setParent($parent)
...@@ -201,7 +207,7 @@ class AbstractUpdateAction extends Param ...@@ -201,7 +207,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Returns the parent document id * Returns the parent document id.
* *
* @return string|int Parent document id * @return string|int Parent document id
*/ */
...@@ -219,9 +225,10 @@ class AbstractUpdateAction extends Param ...@@ -219,9 +225,10 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Set operation type * Set operation type.
*
* @param string $opType Only accept create
* *
* @param string $opType Only accept create
* @return $this * @return $this
*/ */
public function setOpType($opType) public function setOpType($opType)
...@@ -230,7 +237,8 @@ class AbstractUpdateAction extends Param ...@@ -230,7 +237,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Get operation type * Get operation type.
*
* @return string * @return string
*/ */
public function getOpType() public function getOpType()
...@@ -247,9 +255,10 @@ class AbstractUpdateAction extends Param ...@@ -247,9 +255,10 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Set percolate query param * Set percolate query param.
*
* @param string $value percolator filter
* *
* @param string $value percolator filter
* @return $this * @return $this
*/ */
public function setPercolate($value = '*') public function setPercolate($value = '*')
...@@ -258,7 +267,7 @@ class AbstractUpdateAction extends Param ...@@ -258,7 +267,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Get percolate parameter * Get percolate parameter.
* *
* @return string * @return string
*/ */
...@@ -276,9 +285,10 @@ class AbstractUpdateAction extends Param ...@@ -276,9 +285,10 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Set routing query param * Set routing query param.
*
* @param string $value routing
* *
* @param string $value routing
* @return $this * @return $this
*/ */
public function setRouting($value) public function setRouting($value)
...@@ -287,7 +297,7 @@ class AbstractUpdateAction extends Param ...@@ -287,7 +297,7 @@ class AbstractUpdateAction extends Param
} }
/** /**
* Get routing parameter * Get routing parameter.
* *
* @return string * @return string
*/ */
...@@ -305,7 +315,8 @@ class AbstractUpdateAction extends Param ...@@ -305,7 +315,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param array|string $fields * @param array|string $fields
*
* @return $this * @return $this
*/ */
public function setFields($fields) public function setFields($fields)
...@@ -342,7 +353,8 @@ class AbstractUpdateAction extends Param ...@@ -342,7 +353,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param int $num * @param int $num
*
* @return $this * @return $this
*/ */
public function setRetryOnConflict($num) public function setRetryOnConflict($num)
...@@ -367,7 +379,8 @@ class AbstractUpdateAction extends Param ...@@ -367,7 +379,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param string $timestamp * @param string $timestamp
*
* @return $this * @return $this
*/ */
public function setTimestamp($timestamp) public function setTimestamp($timestamp)
...@@ -392,7 +405,8 @@ class AbstractUpdateAction extends Param ...@@ -392,7 +405,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param bool $refresh * @param bool $refresh
*
* @return $this * @return $this
*/ */
public function setRefresh($refresh = true) public function setRefresh($refresh = true)
...@@ -417,7 +431,8 @@ class AbstractUpdateAction extends Param ...@@ -417,7 +431,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param string $timeout * @param string $timeout
*
* @return $this * @return $this
*/ */
public function setTimeout($timeout) public function setTimeout($timeout)
...@@ -442,7 +457,8 @@ class AbstractUpdateAction extends Param ...@@ -442,7 +457,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param string $timeout * @param string $timeout
*
* @return $this * @return $this
*/ */
public function setConsistency($timeout) public function setConsistency($timeout)
...@@ -467,7 +483,8 @@ class AbstractUpdateAction extends Param ...@@ -467,7 +483,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param string $timeout * @param string $timeout
*
* @return $this * @return $this
*/ */
public function setReplication($timeout) public function setReplication($timeout)
...@@ -492,7 +509,8 @@ class AbstractUpdateAction extends Param ...@@ -492,7 +509,8 @@ class AbstractUpdateAction extends Param
} }
/** /**
* @param \Elastica\Document|array $data * @param \Elastica\Document|array $data
*
* @return $this * @return $this
*/ */