summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Filter
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Filter')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php59
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php198
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php52
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php89
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php15
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php20
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php133
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php42
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php20
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php34
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php49
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php76
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php103
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php56
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php84
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php73
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php47
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php95
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php69
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php94
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php78
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php34
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php20
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php60
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php62
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php80
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Query.php91
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Range.php73
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php112
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Script.php47
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Term.php47
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php149
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Type.php59
34 files changed, 2333 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php
new file mode 100644
index 00000000..7c7dc4f7
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php
@@ -0,0 +1,59 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+use Elastica\Param;
+
+/**
+ * Abstract filter object. Should be extended by all filter types.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filters.html
+ */
+abstract class AbstractFilter extends Param
+{
+ /**
+ * Sets the filter cache.
+ *
+ * @param bool $cached Cached
+ *
+ * @return $this
+ */
+ public function setCached($cached = true)
+ {
+ return $this->setParam('_cache', (bool) $cached);
+ }
+
+ /**
+ * Sets the filter cache key.
+ *
+ * @param string $cacheKey Cache key
+ *
+ * @throws \Elastica\Exception\InvalidException If given key is empty
+ *
+ * @return $this
+ */
+ public function setCacheKey($cacheKey)
+ {
+ $cacheKey = (string) $cacheKey;
+
+ if (empty($cacheKey)) {
+ throw new InvalidException('Invalid parameter. Has to be a non empty string');
+ }
+
+ return $this->setParam('_cache_key', (string) $cacheKey);
+ }
+
+ /**
+ * Sets the filter name.
+ *
+ * @param string $name Name
+ *
+ * @return $this
+ */
+ public function setName($name)
+ {
+ return $this->setParam('_name', $name);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php
new file mode 100644
index 00000000..b208afb4
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php
@@ -0,0 +1,198 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Geo distance filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html
+ */
+abstract class AbstractGeoDistance extends AbstractFilter
+{
+ const LOCATION_TYPE_GEOHASH = 'geohash';
+ const LOCATION_TYPE_LATLON = 'latlon';
+
+ /**
+ * Location type.
+ *
+ * Decides if this filter uses latitude/longitude or geohash for the location.
+ * Values are "latlon" or "geohash".
+ *
+ * @var string
+ */
+ protected $_locationType = null;
+
+ /**
+ * Key.
+ *
+ * @var string
+ */
+ protected $_key = null;
+
+ /**
+ * Latitude.
+ *
+ * @var float
+ */
+ protected $_latitude = null;
+
+ /**
+ * Longitude.
+ *
+ * @var float
+ */
+ protected $_longitude = null;
+
+ /**
+ * Geohash.
+ *
+ * @var string
+ */
+ protected $_geohash = null;
+
+ /**
+ * Create GeoDistance object.
+ *
+ * @param string $key Key
+ * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86'
+ *
+ * @internal param string $distance Distance
+ */
+ public function __construct($key, $location)
+ {
+ // Key
+ $this->setKey($key);
+ $this->setLocation($location);
+ }
+
+ /**
+ * @param string $key
+ *
+ * @return $this
+ */
+ public function setKey($key)
+ {
+ $this->_key = $key;
+
+ return $this;
+ }
+
+ /**
+ * @param array|string $location
+ *
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
+ */
+ public function setLocation($location)
+ {
+ // Location
+ if (is_array($location)) { // Latitude/Longitude
+ // Latitude
+ if (isset($location['lat'])) {
+ $this->setLatitude($location['lat']);
+ } else {
+ throw new InvalidException('$location[\'lat\'] has to be set');
+ }
+
+ // Longitude
+ if (isset($location['lon'])) {
+ $this->setLongitude($location['lon']);
+ } else {
+ throw new InvalidException('$location[\'lon\'] has to be set');
+ }
+ } elseif (is_string($location)) { // Geohash
+ $this->setGeohash($location);
+ } else { // Invalid location
+ throw new InvalidException('$location has to be an array (latitude/longitude) or a string (geohash)');
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param float $latitude
+ *
+ * @return $this
+ */
+ public function setLatitude($latitude)
+ {
+ $this->_latitude = (float) $latitude;
+ $this->_locationType = self::LOCATION_TYPE_LATLON;
+
+ return $this;
+ }
+
+ /**
+ * @param float $longitude
+ *
+ * @return $this
+ */
+ public function setLongitude($longitude)
+ {
+ $this->_longitude = (float) $longitude;
+ $this->_locationType = self::LOCATION_TYPE_LATLON;
+
+ return $this;
+ }
+
+ /**
+ * @param string $geohash
+ *
+ * @return $this
+ */
+ public function setGeohash($geohash)
+ {
+ $this->_geohash = $geohash;
+ $this->_locationType = self::LOCATION_TYPE_GEOHASH;
+
+ return $this;
+ }
+
+ /**
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return array|string
+ */
+ protected function _getLocationData()
+ {
+ if ($this->_locationType === self::LOCATION_TYPE_LATLON) { // Latitude/longitude
+ $location = array();
+
+ if (isset($this->_latitude)) { // Latitude
+ $location['lat'] = $this->_latitude;
+ } else {
+ throw new InvalidException('Latitude has to be set');
+ }
+
+ if (isset($this->_longitude)) { // Geohash
+ $location['lon'] = $this->_longitude;
+ } else {
+ throw new InvalidException('Longitude has to be set');
+ }
+ } elseif ($this->_locationType === self::LOCATION_TYPE_GEOHASH) { // Geohash
+ $location = $this->_geohash;
+ } else { // Invalid location type
+ throw new InvalidException('Invalid location type');
+ }
+
+ return $location;
+ }
+
+ /**
+ * @see \Elastica\Param::toArray()
+ *
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ $this->setParam($this->_key, $this->_getLocationData());
+
+ return parent::toArray();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php
new file mode 100644
index 00000000..4f5c0f93
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php
@@ -0,0 +1,52 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * geo_shape filter.
+ *
+ * Filter pre-indexed shape definitions
+ *
+ * @author Bennie Krijger <benniekrijger@gmail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html
+ */
+abstract class AbstractGeoShape extends AbstractFilter
+{
+ const RELATION_INTERSECT = 'intersects';
+ const RELATION_DISJOINT = 'disjoint';
+ const RELATION_CONTAINS = 'within';
+
+ /**
+ * @var string
+ *
+ * elasticsearch path of the pre-indexed shape
+ */
+ protected $_path;
+
+ /**
+ * @var string
+ *
+ * the relation of the 2 shaped: intersects, disjoint, within
+ */
+ protected $_relation = self::RELATION_INTERSECT;
+
+ /**
+ * @param string $relation
+ *
+ * @return $this
+ */
+ public function setRelation($relation)
+ {
+ $this->_relation = $relation;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getRelation()
+ {
+ return $this->_relation;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php
new file mode 100644
index 00000000..06f6daea
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php
@@ -0,0 +1,89 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Multi Abstract filter object. Should be extended by filter types composed of an array of sub filters.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+abstract class AbstractMulti extends AbstractFilter
+{
+ /**
+ * Filters.
+ *
+ * @var array
+ */
+ protected $_filters = array();
+
+ /**
+ * @param \Elastica\Filter\AbstractFilter $filters
+ */
+ public function __construct(array $filters = array())
+ {
+ if (!empty($filters)) {
+ $this->setFilters($filters);
+ }
+ }
+
+ /**
+ * Add filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function addFilter(AbstractFilter $filter)
+ {
+ $this->_filters[] = $filter->toArray();
+
+ return $this;
+ }
+
+ /**
+ * Set filters.
+ *
+ * @param array $filters
+ *
+ * @return $this
+ */
+ public function setFilters(array $filters)
+ {
+ $this->_filters = array();
+
+ foreach ($filters as $filter) {
+ $this->addFilter($filter);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return array Filters
+ */
+ public function getFilters()
+ {
+ return $this->_filters;
+ }
+
+ /**
+ * @see \Elastica\Param::toArray()
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ $data = parent::toArray();
+ $name = $this->_getBaseName();
+ $filterData = $data[$name];
+
+ if (empty($filterData)) {
+ $filterData = $this->_filters;
+ } else {
+ $filterData['filters'] = $this->_filters;
+ }
+
+ $data[$name] = $filterData;
+
+ return $data;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php
new file mode 100644
index 00000000..0d30f83f
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php
@@ -0,0 +1,15 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Bool Filter.
+ *
+ * This class is for backward compatibility reason for all php < 7 versions. For PHP 7 and above use BoolFilter as Bool is reserved.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html
+ */
+class Bool extends BoolFilter
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php
new file mode 100644
index 00000000..8a08ea9c
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php
@@ -0,0 +1,20 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * And Filter.
+ *
+ * @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
+ */
+class BoolAnd extends AbstractMulti
+{
+ /**
+ * @return string
+ */
+ protected function _getBaseName()
+ {
+ return 'and';
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php
new file mode 100644
index 00000000..5a488b77
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php
@@ -0,0 +1,133 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Bool Filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html
+ */
+class BoolFilter extends AbstractFilter
+{
+ /**
+ * Must.
+ *
+ * @var array
+ */
+ protected $_must = array();
+
+ /**
+ * Should.
+ *
+ * @var array
+ */
+ protected $_should = array();
+
+ /**
+ * Must not.
+ *
+ * @var array
+ */
+ protected $_mustNot = array();
+
+ /**
+ * Adds should filter.
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @return $this
+ */
+ public function addShould($args)
+ {
+ return $this->_addFilter('should', $args);
+ }
+
+ /**
+ * Adds must filter.
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @return $this
+ */
+ public function addMust($args)
+ {
+ return $this->_addFilter('must', $args);
+ }
+
+ /**
+ * Adds mustNot filter.
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @return $this
+ */
+ public function addMustNot($args)
+ {
+ return $this->_addFilter('mustNot', $args);
+ }
+
+ /**
+ * Adds general filter based on type.
+ *
+ * @param string $type Filter type
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
+ */
+ protected function _addFilter($type, $args)
+ {
+ if ($args instanceof AbstractFilter) {
+ $args = $args->toArray();
+ } elseif (!is_array($args)) {
+ throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Filter');
+ } else {
+ $parsedArgs = array();
+ foreach ($args as $filter) {
+ if ($filter instanceof AbstractFilter) {
+ $parsedArgs[] = $filter->toArray();
+ }
+ }
+ $args = $parsedArgs;
+ }
+
+ $varName = '_'.$type;
+ $this->{$varName}[] = $args;
+
+ return $this;
+ }
+
+ /**
+ * Converts bool filter to array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array Filter array
+ */
+ public function toArray()
+ {
+ $args = array();
+
+ if (!empty($this->_must)) {
+ $args['bool']['must'] = $this->_must;
+ }
+
+ if (!empty($this->_should)) {
+ $args['bool']['should'] = $this->_should;
+ }
+
+ if (!empty($this->_mustNot)) {
+ $args['bool']['must_not'] = $this->_mustNot;
+ }
+
+ if (isset($args['bool'])) {
+ $args['bool'] = array_merge($args['bool'], $this->getParams());
+ }
+
+ return $args;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php
new file mode 100644
index 00000000..81db7f65
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php
@@ -0,0 +1,42 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Not Filter.
+ *
+ * @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-not-filter.html
+ */
+class BoolNot extends AbstractFilter
+{
+ /**
+ * Creates Not filter query.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter Filter object
+ */
+ public function __construct(AbstractFilter $filter)
+ {
+ $this->setFilter($filter);
+ }
+
+ /**
+ * Set filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function setFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('filter', $filter->toArray());
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getBaseName()
+ {
+ return 'not';
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php
new file mode 100644
index 00000000..9091e496
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php
@@ -0,0 +1,20 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Or Filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-or-filter.html
+ */
+class BoolOr extends AbstractMulti
+{
+ /**
+ * @return string
+ */
+ protected function _getBaseName()
+ {
+ return 'or';
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php
new file mode 100644
index 00000000..d6dc9962
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php
@@ -0,0 +1,34 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Exists query.
+ *
+ * @author Oleg Cherniy <oleg.cherniy@gmail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-filter.html
+ */
+class Exists extends AbstractFilter
+{
+ /**
+ * Construct exists filter.
+ *
+ * @param string $field
+ */
+ public function __construct($field)
+ {
+ $this->setField($field);
+ }
+
+ /**
+ * Set field.
+ *
+ * @param string $field
+ *
+ * @return $this
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', $field);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php
new file mode 100644
index 00000000..f67febe3
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php
@@ -0,0 +1,49 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Geo bounding box filter.
+ *
+ * @author Fabian Vogler <fabian@equivalence.ch>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-filter.html
+ */
+class GeoBoundingBox extends AbstractFilter
+{
+ /**
+ * Construct BoundingBoxFilter.
+ *
+ * @param string $key Key
+ * @param array $coordinates Array with top left coordinate as first and bottom right coordinate as second element
+ */
+ public function __construct($key, array $coordinates)
+ {
+ $this->addCoordinates($key, $coordinates);
+ }
+
+ /**
+ * Add coordinates.
+ *
+ * @param string $key Key
+ * @param array $coordinates Array with top left coordinate as first and bottom right coordinate as second element
+ *
+ * @throws \Elastica\Exception\InvalidException If $coordinates doesn't have two elements
+ *
+ * @return $this
+ */
+ public function addCoordinates($key, array $coordinates)
+ {
+ if (!isset($coordinates[0]) || !isset($coordinates[1])) {
+ throw new InvalidException('expected $coordinates to be an array with two elements');
+ }
+
+ $this->setParam($key, array(
+ 'top_left' => $coordinates[0],
+ 'bottom_right' => $coordinates[1],
+ ));
+
+ return $this;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php
new file mode 100644
index 00000000..f4cb51d9
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php
@@ -0,0 +1,76 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Geo distance filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html
+ */
+class GeoDistance extends AbstractGeoDistance
+{
+ const DISTANCE_TYPE_ARC = 'arc';
+ const DISTANCE_TYPE_PLANE = 'plane';
+ const DISTANCE_TYPE_SLOPPY_ARC = 'sloppy_arc';
+
+ const OPTIMIZE_BBOX_MEMORY = 'memory';
+ const OPTIMIZE_BBOX_INDEXED = 'indexed';
+ const OPTIMIZE_BBOX_NONE = 'none';
+
+ /**
+ * Create GeoDistance object.
+ *
+ * @param string $key Key
+ * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86'
+ * @param string $distance Distance
+ *
+ * @throws \Elastica\Exception\InvalidException
+ */
+ public function __construct($key, $location, $distance)
+ {
+ parent::__construct($key, $location);
+
+ $this->setDistance($distance);
+ }
+
+ /**
+ * @param string $distance
+ *
+ * @return $this
+ */
+ public function setDistance($distance)
+ {
+ $this->setParam('distance', $distance);
+
+ return $this;
+ }
+
+ /**
+ * See DISTANCE_TYPE_* constants.
+ *
+ * @param string $distanceType
+ *
+ * @return $this
+ */
+ public function setDistanceType($distanceType)
+ {
+ $this->setParam('distance_type', $distanceType);
+
+ return $this;
+ }
+
+ /**
+ * See OPTIMIZE_BBOX_* constants.
+ *
+ * @param string $optimizeBbox
+ *
+ * @return $this
+ */
+ public function setOptimizeBbox($optimizeBbox)
+ {
+ $this->setParam('optimize_bbox', $optimizeBbox);
+
+ return $this;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php
new file mode 100644
index 00000000..f5cbbeb7
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php
@@ -0,0 +1,103 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Geo distance filter.
+ *
+ * @author munkie
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-range-filter.html
+ */
+class GeoDistanceRange extends AbstractGeoDistance
+{
+ const RANGE_FROM = 'from';
+ const RANGE_TO = 'to';
+ const RANGE_LT = 'lt';
+ const RANGE_LTE = 'lte';
+ const RANGE_GT = 'gt';
+ const RANGE_GTE = 'gte';
+
+ const RANGE_INCLUDE_LOWER = 'include_lower';
+ const RANGE_INCLUDE_UPPER = 'include_upper';
+
+ /**
+ * @var array
+ */
+ protected $_ranges = array();
+
+ /**
+ * @param string $key
+ * @param array|string $location
+ * @param array $ranges
+ *
+ * @internal param string $distance
+ */
+ public function __construct($key, $location, array $ranges = array())
+ {
+ parent::__construct($key, $location);
+
+ if (!empty($ranges)) {
+ $this->setRanges($ranges);
+ }
+ }
+
+ /**
+ * @param array $ranges
+ *
+ * @return $this
+ */
+ public function setRanges(array $ranges)
+ {
+ $this->_ranges = array();
+
+ foreach ($ranges as $key => $value) {
+ $this->setRange($key, $value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ *
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
+ */
+ public function setRange($key, $value)
+ {
+ switch ($key) {
+ case self::RANGE_TO:
+ case self::RANGE_FROM:
+ case self::RANGE_GT:
+ case self::RANGE_GTE:
+ case self::RANGE_LT:
+ case self::RANGE_LTE:
+ break;
+ case self::RANGE_INCLUDE_LOWER:
+ case self::RANGE_INCLUDE_UPPER:
+ $value = (boolean) $value;
+ break;
+ default:
+ throw new InvalidException('Invalid range parameter given: '.$key);
+ }
+ $this->_ranges[$key] = $value;
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ foreach ($this->_ranges as $key => $value) {
+ $this->setParam($key, $value);
+ }
+
+ return parent::toArray();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php
new file mode 100644
index 00000000..86ca2b80
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php
@@ -0,0 +1,56 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Geo polygon filter.
+ *
+ * @author Michael Maclean <mgdm@php.net>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-filter.html
+ */
+class GeoPolygon extends AbstractFilter
+{
+ /**
+ * Key.
+ *
+ * @var string Key
+ */
+ protected $_key = '';
+
+ /**
+ * Points making up polygon.
+ *
+ * @var array Points making up polygon
+ */
+ protected $_points = array();
+
+ /**
+ * Construct polygon filter.
+ *
+ * @param string $key Key
+ * @param array $points Points making up polygon
+ */
+ public function __construct($key, array $points)
+ {
+ $this->_key = $key;
+ $this->_points = $points;
+ }
+
+ /**
+ * Converts filter to array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ return array(
+ 'geo_polygon' => array(
+ $this->_key => array(
+ 'points' => $this->_points,
+ ),
+ ),
+ );
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php
new file mode 100644
index 00000000..d07cffff
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php
@@ -0,0 +1,84 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * geo_shape filter for pre-indexed shapes.
+ *
+ * Filter pre-indexed shape definitions
+ *
+ * @author Bennie Krijger <benniekrijger@gmail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html
+ */
+class GeoShapePreIndexed extends AbstractGeoShape
+{
+ /**
+ * elasticsearch id of the pre-indexed shape.
+ *
+ * @var string
+ */
+ protected $_indexedId;
+
+ /**
+ * elasticsearch type of the pre-indexed shape.
+ *
+ * @var string
+ */
+ protected $_indexedType;
+
+ /**
+ * elasticsearch index of the pre-indexed shape.
+ *
+ * @var string
+ */
+ protected $_indexedIndex;
+
+ /**
+ * elasticsearch path/field name of the pre-indexed shape.
+ *
+ * @var string
+ */
+ protected $_indexedPath;
+
+ /**
+ * Construct geo_shape filter with a pre-indexed shape.
+ *
+ * @param string $path The path/field of the shape searched
+ * @param string $indexedId Id of the pre-indexed shape
+ * @param string $indexedType Type of the pre-indexed shape
+ * @param string $indexedIndex Index of the pre-indexed shape
+ * @param string $indexedPath Path of the pre-indexed shape
+ */
+ public function __construct($path, $indexedId, $indexedType, $indexedIndex, $indexedPath)
+ {
+ $this->_path = $path;
+ $this->_indexedId = $indexedId;
+ $this->_indexedType = $indexedType;
+ $this->_indexedIndex = $indexedIndex;
+ $this->_indexedPath = $indexedPath;
+ }
+
+ /**
+ * Converts filter to array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ return array(
+ 'geo_shape' => array(
+ $this->_path => array(
+ 'indexed_shape' => array(
+ 'id' => $this->_indexedId,
+ 'type' => $this->_indexedType,
+ 'index' => $this->_indexedIndex,
+ 'path' => $this->_indexedPath,
+ ),
+ 'relation' => $this->_relation,
+ ),
+ ),
+ );
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php
new file mode 100644
index 00000000..0f25beeb
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php
@@ -0,0 +1,73 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * geo_shape filter or provided shapes.
+ *
+ * Filter provided shape definitions
+ *
+ * @author BennieKrijger <benniekrijger@gmail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html
+ */
+class GeoShapeProvided extends AbstractGeoShape
+{
+ const TYPE_ENVELOPE = 'envelope';
+ const TYPE_MULTIPOINT = 'multipoint';
+ const TYPE_POINT = 'point';
+ const TYPE_MULTIPOLYGON = 'multipolygon';
+ const TYPE_LINESTRING = 'linestring';
+ const TYPE_POLYGON = 'polygon';
+
+ /**
+ * Type of the geo_shape.
+ *
+ * @var string
+ */
+ protected $_shapeType;
+
+ /**
+ * Coordinates making up geo_shape.
+ *
+ * @var array Coordinates making up geo_shape
+ */
+ protected $_coordinates;
+
+ /**
+ * Construct geo_shape filter.
+ *
+ * @param string $path The path/field of the shape searched
+ * @param array $coordinates Points making up the shape
+ * @param string $shapeType Type of the geo_shape:
+ * point, envelope, linestring, polygon,
+ * multipoint or multipolygon
+ */
+ public function __construct($path, array $coordinates, $shapeType = self::TYPE_ENVELOPE)
+ {
+ $this->_path = $path;
+ $this->_shapeType = $shapeType;
+ $this->_coordinates = $coordinates;
+ }
+
+ /**
+ * Converts filter to array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ return array(
+ 'geo_shape' => array(
+ $this->_path => array(
+ 'shape' => array(
+ 'type' => $this->_shapeType,
+ 'coordinates' => $this->_coordinates,
+ ),
+ 'relation' => $this->_relation,
+ ),
+ ),
+ );
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php
new file mode 100644
index 00000000..dd147152
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php
@@ -0,0 +1,47 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Class GeohashCell.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-filter.html
+ */
+class GeohashCell extends AbstractGeoDistance
+{
+ /**
+ * @param string $key The field on which to filter
+ * @param array|string $location Location as coordinates array or geohash string ['lat' => 40.3, 'lon' => 45.2]
+ * @param string|int $precision Integer length of geohash prefix or distance (3, or "50m")
+ * @param bool $neighbors If true, filters cells next to the given cell.
+ */
+ public function __construct($key, $location, $precision = -1, $neighbors = false)
+ {
+ parent::__construct($key, $location);
+ $this->setPrecision($precision);
+ $this->setNeighbors($neighbors);
+ }
+
+ /**
+ * Set the precision for this filter.
+ *
+ * @param string|int $precision Integer length of geohash prefix or distance (3, or "50m")
+ *
+ * @return $this
+ */
+ public function setPrecision($precision)
+ {
+ return $this->setParam('precision', $precision);
+ }
+
+ /**
+ * Set the neighbors option for this filter.
+ *
+ * @param bool $neighbors If true, filters cells next to the given cell.
+ *
+ * @return $this
+ */
+ public function setNeighbors($neighbors)
+ {
+ return $this->setParam('neighbors', (bool) $neighbors);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php b/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
new file mode 100644
index 00000000..2c4cc0d6
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
@@ -0,0 +1,95 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Returns parent documents having child docs matching the query.
+ *
+ * @author Fabian Vogler <fabian@equivalence.ch>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html
+ */
+class HasChild extends AbstractFilter
+{
+ /**
+ * Construct HasChild filter.
+ *
+ * @param string|\Elastica\Query|\Elastica\Filter\AbstractFilter $query Query string or a Elastica\Query object or a filter
+ * @param string|\Elastica\Type $type Child document type
+ */
+ public function __construct($query, $type = null)
+ {
+ $this->setType($type);
+ if ($query instanceof AbstractFilter) {
+ $this->setFilter($query);
+ } else {
+ $this->setQuery($query);
+ }
+ }
+
+ /**
+ * Sets query object.
+ *
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
+ */
+ public function setQuery($query)
+ {
+ $query = \Elastica\Query::create($query);
+ $data = $query->toArray();
+
+ return $this->setParam('query', $data['query']);
+ }
+
+ /**
+ * Sets the filter object.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function setFilter($filter)
+ {
+ return $this->setParam('filter', $filter->toArray());
+ }
+
+ /**
+ * Set type of the child document.
+ *
+ * @param string|\Elastica\Type $type Child document type
+ *
+ * @return $this
+ */
+ public function setType($type)
+ {
+ if ($type instanceof \Elastica\Type) {
+ $type = $type->getName();
+ }
+
+ return $this->setParam('type', (string) $type);
+ }
+
+ /**
+ * Set minimum number of children are required to match for the parent doc to be considered a match.
+ *
+ * @param int $count
+ *
+ * @return $this
+ */
+ public function setMinimumChildrenCount($count)
+ {
+ return $this->setParam('min_children', (int) $count);
+ }
+
+ /**
+ * Set maximum number of children are required to match for the parent doc to be considered a match.
+ *
+ * @param int $count
+ *
+ * @return $this
+ */
+ public function setMaximumChildrenCount($count)
+ {
+ return $this->setParam('max_children', (int) $count);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php b/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php
new file mode 100644
index 00000000..73a2dc5a
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php
@@ -0,0 +1,69 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Returns child documents having parent docs matching the query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-filter.html
+ */
+class HasParent extends AbstractFilter
+{
+ /**
+ * Construct HasParent filter.
+ *
+ * @param string|\Elastica\Query|\Elastica\Filter\AbstractFilter $query Query string or a Query object or a filter
+ * @param string|\Elastica\Type $type Parent document type
+ */
+ public function __construct($query, $type)
+ {
+ if ($query instanceof AbstractFilter) {
+ $this->setFilter($query);
+ } else {
+ $this->setQuery($query);
+ }
+ $this->setType($type);
+ }
+
+ /**
+ * Sets query object.
+ *
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
+ */
+ public function setQuery($query)
+ {
+ $query = \Elastica\Query::create($query);
+ $data = $query->toArray();
+
+ return $this->setParam('query', $data['query']);
+ }
+
+ /**
+ * Sets filter object.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function setFilter($filter)
+ {
+ return $this->setParam('filter', $filter->toArray());
+ }
+
+ /**
+ * Set type of the parent document.
+ *
+ * @param string|\Elastica\Type $type Parent document type
+ *
+ * @return $this
+ */
+ public function setType($type)
+ {
+ if ($type instanceof \Elastica\Type) {
+ $type = $type->getName();
+ }
+
+ return $this->setParam('type', (string) $type);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php
new file mode 100644
index 00000000..bfb8cc48
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php
@@ -0,0 +1,94 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Type as ElasticaType;
+
+/**
+ * Ids Filter.
+ *
+ * @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-filter.html
+ */
+class Ids extends AbstractFilter
+{
+ /**
+ * Creates filter object.
+ *
+ * @param string|\Elastica\Type $type Type to filter on
+ * @param array $ids List of ids
+ */
+ public function __construct($type = null, array $ids = array())
+ {
+ $this->setType($type);
+ $this->setIds($ids);
+ }
+
+ /**
+ * Adds one more filter to the and filter.
+ *
+ * @param string $id Adds id to filter
+ *
+ * @return $this
+ */
+ public function addId($id)
+ {
+ return $this->addParam('values', $id);
+ }
+
+ /**
+ * Adds one more type to query.
+ *
+ * @param string|\Elastica\Type $type Type name or object
+ *
+ * @return $this
+ */
+ public function addType($type)
+ {
+ if ($type instanceof ElasticaType) {
+ $type = $type->getName();
+ } elseif (empty($type) && !is_numeric($type)) {
+ // TODO: Shouldn't this throw an exception?
+ // A type can be 0, but cannot be empty
+ return $this;
+ }
+
+ return $this->addParam('type', $type);
+ }
+
+ /**
+ * Set type.
+ *
+ * @param string|\Elastica\Type $type Type name or object
+ *
+ * @return $this
+ */
+ public function setType($type)
+ {
+ if ($type instanceof ElasticaType) {
+ $type = $type->getName();
+ } elseif (empty($type) && !is_numeric($type)) {
+ // TODO: Shouldn't this throw an exception or let handling of invalid params to ES?
+ // A type can be 0, but cannot be empty
+ return $this;
+ }
+
+ return $this->setParam('type', $type);
+ }
+
+ /**
+ * Sets the ids to filter.
+ *
+ * @param array|string $ids List of ids
+ *
+ * @return $this
+ */
+ public function setIds($ids)
+ {
+ if (!is_array($ids)) {
+ $ids = array($ids);
+ }
+
+ return $this->setParam('values', $ids);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php
new file mode 100644
index 00000000..ffaf5975
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php
@@ -0,0 +1,78 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Index as ElasticaIndex;
+
+/**
+ * Class Indices.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-indices-filter.html
+ */
+class Indices extends AbstractFilter
+{
+ /**
+ * @param AbstractFilter $filter filter which will be applied to docs in the specified indices
+ * @param mixed[] $indices
+ */
+ public function __construct(AbstractFilter $filter, array $indices)
+ {
+ $this->setIndices($indices)->setFilter($filter);
+ }
+
+ /**
+ * Set the indices on which this filter should be applied.
+ *
+ * @param mixed[] $indices
+ *
+ * @return $this
+ */
+ public function setIndices(array $indices)
+ {
+ $this->setParam('indices', array());
+ foreach ($indices as $index) {
+ $this->addIndex($index);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds one more index on which this filter should be applied.
+ *
+ * @param string|\Elastica\Index $index
+ *
+ * @return $this
+ */
+ public function addIndex($index)
+ {
+ if ($index instanceof ElasticaIndex) {
+ $index = $index->getName();
+ }
+
+ return $this->addParam('indices', (string) $index);
+ }
+
+ /**
+ * Set the filter to be applied to docs in the specified indices.
+ *
+ * @param AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function setFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('filter', $filter->toArray());
+ }
+
+ /**
+ * Set the filter to be applied to docs in indices which do not match those specified in the "indices" parameter.
+ *
+ * @param AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function setNoMatchFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('no_match_filter', $filter->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php
new file mode 100644
index 00000000..bf3f8e13
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php
@@ -0,0 +1,34 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Limit Filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-limit-filter.html
+ */
+class Limit extends AbstractFilter
+{
+ /**
+ * Construct limit filter.
+ *
+ * @param int $limit Limit
+ */
+ public function __construct($limit)
+ {
+ $this->setLimit($limit);
+ }
+
+ /**
+ * Set the limit.
+ *
+ * @param int $limit Limit
+ *
+ * @return $this
+ */
+ public function setLimit($limit)
+ {
+ return $this->setParam('value', (int) $limit);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php b/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php
new file mode 100644
index 00000000..607c5fd1
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php
@@ -0,0 +1,20 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Match all filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-filter.html
+ */
+class MatchAll extends AbstractFilter
+{
+ /**
+ * Creates match all filter.
+ */
+ public function __construct()
+ {
+ $this->_params = new \stdClass();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php
new file mode 100644
index 00000000..9b157b2c
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php
@@ -0,0 +1,60 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Missing Filter.
+ *
+ * @author Maciej Wiercinski <maciej@wiercinski.net>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html
+ */
+class Missing extends AbstractFilter
+{
+ /**
+ * Construct missing filter.
+ *
+ * @param string $field OPTIONAL
+ */
+ public function __construct($field = '')
+ {
+ if (strlen($field)) {
+ $this->setField($field);
+ }
+ }
+
+ /**
+ * Set field.
+ *
+ * @param string $field
+ *
+ * @return $this
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', (string) $field);
+ }
+
+ /**
+ * Set "existence" parameter.
+ *
+ * @param bool $existence
+ *
+ * @return $this
+ */
+ public function setExistence($existence)
+ {
+ return $this->setParam('existence', (bool) $existence);
+ }
+
+ /**
+ * Set "null_value" parameter.
+ *
+ * @param bool $nullValue
+ *
+ * @return $this
+ */
+ public function setNullValue($nullValue)
+ {
+ return $this->setParam('null_value', (bool) $nullValue);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php
new file mode 100644
index 00000000..ad21bc7e
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php
@@ -0,0 +1,62 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Query\AbstractQuery;
+
+/**
+ * Nested filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-filter.html
+ */
+class Nested extends AbstractFilter
+{
+ /**
+ * Adds field to mlt filter.
+ *
+ * @param string $path Nested object path
+ *
+ * @return $this
+ */
+ public function setPath($path)
+ {
+ return $this->setParam('path', $path);
+ }
+
+ /**
+ * Sets nested query.
+ *
+ * @param \Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
+ */
+ public function setQuery(AbstractQuery $query)
+ {
+ return $this->setParam('query', $query->toArray());
+ }
+
+ /**
+ * Sets nested filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
+ */
+ public function setFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('filter', $filter->toArray());
+ }
+
+ /**
+ * Set join option.
+ *
+ * @param bool $join
+ *
+ * @return $this
+ */
+ public function setJoin($join)
+ {
+ return $this->setParam('join', (bool) $join);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php b/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php
new file mode 100644
index 00000000..08342616
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php
@@ -0,0 +1,13 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Numeric Range Filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-filter.html
+ */
+class NumericRange extends Range
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php
new file mode 100644
index 00000000..e845fd73
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php
@@ -0,0 +1,80 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Prefix filter.
+ *
+ * @author Jasper van Wanrooy <jasper@vanwanrooy.net>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-filter.html
+ */
+class Prefix extends AbstractFilter
+{
+ /**
+ * Holds the name of the field for the prefix.
+ *
+ * @var string
+ */
+ protected $_field = '';
+
+ /**
+ * Holds the prefix string.
+ *
+ * @var string
+ */
+ protected $_prefix = '';
+
+ /**
+ * Creates prefix filter.
+ *
+ * @param string $field Field name
+ * @param string $prefix Prefix string
+ */
+ public function __construct($field = '', $prefix = '')
+ {
+ $this->setField($field);
+ $this->setPrefix($prefix);
+ }
+
+ /**
+ * Sets the name of the prefix field.
+ *
+ * @param string $field Field name
+ *
+ * @return $this
+ */
+ public function setField($field)
+ {
+ $this->_field = $field;
+
+ return $this;
+ }
+
+ /**
+ * Sets the prefix string.
+ *
+ * @param string $prefix Prefix string
+ *
+ * @return $this
+ */
+ public function setPrefix($prefix)
+ {
+ $this->_prefix = $prefix;
+
+ return $this;
+ }
+
+ /**
+ * Converts object to an array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array data array
+ */
+ public function toArray()
+ {
+ $this->setParam($this->_field, $this->_prefix);
+
+ return parent::toArray();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php
new file mode 100644
index 00000000..acb6a124
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php
@@ -0,0 +1,91 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+use Elastica\Query\AbstractQuery;
+
+/**
+ * Query filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-filter.html
+ */
+class Query extends AbstractFilter
+{
+ /**
+ * Query.
+ *
+ * @var array
+ */
+ protected $_query;
+
+ /**
+ * Construct query filter.
+ *
+ * @param array|\Elastica\Query\AbstractQuery $query
+ */
+ public function __construct($query = null)
+ {
+ if (!is_null($query)) {
+ $this->setQuery($query);
+ }
+ }
+
+ /**
+ * Set query.
+ *
+ * @param array|\Elastica\Query\AbstractQuery $query
+ *
+ * @throws \Elastica\Exception\InvalidException If parameter is invalid
+ *
+ * @return $this
+ */
+ public function setQuery($query)
+ {
+ if (!$query instanceof AbstractQuery && !is_array($query)) {
+ throw new InvalidException('expected an array or instance of Elastica\Query\AbstractQuery');
+ }
+
+ if ($query instanceof AbstractQuery) {
+ $query = $query->toArray();
+ }
+
+ $this->_query = $query;
+
+ return $this;
+ }
+
+ /**
+ * @see \Elastica\Param::_getBaseName()
+ */
+ protected function _getBaseName()
+ {
+ if (empty($this->_params)) {
+ return 'query';
+ } else {
+ return 'fquery';
+ }
+ }
+
+ /**
+ * @see \Elastica\Param::toArray()
+ */
+ public function toArray()
+ {
+ $data = parent::toArray();
+
+ $name = $this->_getBaseName();
+ $filterData = $data[$name];
+
+ if (empty($filterData)) {
+ $filterData = $this->_query;
+ } else {
+ $filterData['query'] = $this->_query;
+ }
+
+ $data[$name] = $filterData;
+
+ return $data;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php
new file mode 100644
index 00000000..1e7bf132
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php
@@ -0,0 +1,73 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Range Filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-filter.html
+ */
+class Range extends AbstractFilter
+{
+ /**
+ * Fields.
+ *
+ * @var array Fields
+ */
+ protected $_fields = array();
+
+ /**
+ * Construct range filter.
+ *
+ * @param string $fieldName Field name
+ * @param array $args Field arguments
+ */
+ public function __construct($fieldName = '', array $args = array())
+ {
+ if ($fieldName) {
+ $this->addField($fieldName, $args);
+ }
+ }
+
+ /**
+ * Ads a field with arguments to the range query.
+ *
+ * @param string $fieldName Field name
+ * @param array $args Field arguments
+ *
+ * @return $this
+ */
+ public function addField($fieldName, array $args)
+ {
+ $this->_fields[$fieldName] = $args;
+
+ return $this;
+ }
+
+ /**
+ * Set execution mode.
+ *
+ * @param string $execution Options: "index" or "fielddata"
+ *
+ * @return $this
+ */
+ public function setExecution($execution)
+ {
+ return $this->setParam('execution', (string) $execution);
+ }
+
+ /**
+ * Converts object to array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array Filter array
+ */
+ public function toArray()
+ {
+ $this->setParams(array_merge($this->getParams(), $this->_fields));
+
+ return parent::toArray();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
new file mode 100644
index 00000000..612dc434
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
@@ -0,0 +1,112 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Regexp filter.
+ *
+ * @author Timothy Lamb <trash80@gmail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-filter.html
+ */
+class Regexp extends AbstractFilter
+{
+ /**
+ * Holds the name of the field for the regular expression.
+ *
+ * @var string
+ */
+ protected $_field = '';
+
+ /**
+ * Holds the regexp string.
+ *
+ * @var string
+ */
+ protected $_regexp = '';
+
+ /**
+ * Holds the regexp options.
+ *
+ * @var array
+ */
+ protected $_options = array();
+
+ /**
+ * Create Regexp object.
+ *
+ * @param string $field Field name
+ * @param string $regexp Regular expression
+ * @param array $options Regular expression options
+ *
+ * @throws \Elastica\Exception\InvalidException
+ */
+ public function __construct($field = '', $regexp = '', $options = array())
+ {
+ $this->setField($field);
+ $this->setRegexp($regexp);
+ $this->setOptions($options);
+ }
+
+ /**
+ * Sets the name of the regexp field.
+ *
+ * @param string $field Field name
+ *
+ * @return $this
+ */
+ public function setField($field)
+ {
+ $this->_field = $field;
+
+ return $this;
+ }
+
+ /**
+ * Sets the regular expression query string.
+ *
+ * @param string $regexp Regular expression
+ *
+ * @return $this
+ */
+ public function setRegexp($regexp)
+ {
+ $this->_regexp = $regexp;
+
+ return $this;
+ }
+
+ /**
+ * Sets the regular expression query options.
+ *
+ * @param array $options Regular expression options
+ *
+ * @return $this
+ */
+ public function setOptions($options)
+ {
+ $this->_options = $options;
+
+ return $this;
+ }
+
+ /**
+ * Converts object to an array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array data array
+ */
+ public function toArray()
+ {
+ if (count($this->_options) > 0) {
+ $options = array('value' => $this->_regexp);
+ $options = array_merge($options, $this->_options);
+
+ $this->setParam($this->_field, $options);
+ } else {
+ $this->setParam($this->_field, $this->_regexp);
+ }
+
+ return parent::toArray();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php
new file mode 100644
index 00000000..2c8d34bf
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php
@@ -0,0 +1,47 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica;
+
+/**
+ * Script filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-filter.html
+ */
+class Script extends AbstractFilter
+{
+ /**
+ * Query object.
+ *
+ * @var array|\Elastica\Query\AbstractQuery
+ */
+ protected $_query = null;
+
+ /**
+ * Construct script filter.
+ *
+ * @param array|string|\Elastica\Script $script OPTIONAL Script
+ */
+ public function __construct($script = null)
+ {
+ if ($script) {
+ $this->setScript($script);
+ }
+ }
+
+ /**
+ * Sets script object.
+ *
+ * @param \Elastica\Script|string|array $script
+ *
+ * @return $this
+ */
+ public function setScript($script)
+ {
+ $script = Elastica\Script::create($script);
+
+ return $this->setParams($script->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php
new file mode 100644
index 00000000..2a387318
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php
@@ -0,0 +1,47 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Term query.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
+ */
+class Term extends AbstractFilter
+{
+ /**
+ * Construct term filter.
+ *
+ * @param array $term Term array
+ */
+ public function __construct(array $term = array())
+ {
+ $this->setRawTerm($term);
+ }
+
+ /**
+ * Sets/overwrites key and term directly.
+ *
+ * @param array $term Key value pair
+ *
+ * @return $this
+ */
+ public function setRawTerm(array $term)
+ {
+ return $this->setParams($term);
+ }
+
+ /**
+ * Adds a term to the term query.
+ *
+ * @param string $key Key to query
+ * @param string|array $value Values(s) for the query. Boost can be set with array
+ *
+ * @return $this
+ */
+ public function setTerm($key, $value)
+ {
+ return $this->setRawTerm(array($key => $value));
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
new file mode 100644
index 00000000..c099ab3d
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
@@ -0,0 +1,149 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Terms filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
+ */
+class Terms extends AbstractFilter
+{
+ /**
+ * Terms.
+ *
+ * @var array Terms
+ */
+ protected $_terms = array();
+
+ /**
+ * Params.
+ *
+ * @var array Params
+ */
+ protected $_params = array();
+
+ /**
+ * Terms key.
+ *
+ * @var string Terms key
+ */
+ protected $_key = '';
+
+ /**
+ * Creates terms filter.
+ *
+ * @param string $key Terms key
+ * @param array $terms Terms values
+ */
+ public function __construct($key = '', array $terms = array())
+ {
+ $this->setTerms($key, $terms);
+ }
+
+ /**
+ * Sets key and terms for the filter.
+ *
+ * @param string $key Terms key
+ * @param array $terms Terms for the query.
+ *
+ * @return $this
+ */
+ public function setTerms($key, array $terms)
+ {
+ $this->_key = $key;
+ $this->_terms = array_values($terms);
+
+ return $this;
+ }
+
+ /**
+ * Set the lookup parameters for this filter.
+ *
+ * @param string $key terms key
+ * @param string|\Elastica\Type $type document type from which to fetch the terms values
+ * @param string $id id of the document from which to fetch the terms values
+ * @param string $path the field from which to fetch the values for the filter
+ * @param string|array|\Elastica\Index $options An array of options or the index from which to fetch the terms values. Defaults to the current index.
+ *
+ * @return $this
+ */
+ public function setLookup($key, $type, $id, $path, $options = array())
+ {
+ $this->_key = $key;
+ if ($type instanceof \Elastica\Type) {
+ $type = $type->getName();
+ }
+ $this->_terms = array(
+ 'type' => $type,
+ 'id' => $id,
+ 'path' => $path,
+ );
+
+ $index = $options;
+ if (is_array($options)) {
+ if (isset($options['index'])) {
+ $index = $options['index'];
+ unset($options['index']);
+ }
+ $this->_terms = array_merge($options, $this->_terms);
+ }
+
+ if (!is_null($index)) {
+ if ($index instanceof \Elastica\Index) {
+ $index = $index->getName();
+ }
+ $this->_terms['index'] = $index;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds an additional term to the query.
+ *
+ * @param string $term Filter term
+ *
+ * @return $this
+ */
+ public function addTerm($term)
+ {
+ $this->_terms[] = $term;
+
+ return $this;
+ }
+
+ /**
+ * Converts object to an array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ if (empty($this->_key)) {
+ throw new InvalidException('Terms key has to be set');
+ }
+ $this->_params[$this->_key] = $this->_terms;
+
+ return array('terms' => $this->_params);
+ }
+
+ /**
+ * Set execution mode.
+ *
+ * @param string $execution Options: "bool", "and", "or", "plain" or "fielddata"
+ *
+ * @return $this
+ */
+ public function setExecution($execution)
+ {
+ return $this->setParam('execution', (string) $execution);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php
new file mode 100644
index 00000000..f9c17813
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php
@@ -0,0 +1,59 @@
+<?php
+namespace Elastica\Filter;
+
+/**
+ * Type Filter.
+ *
+ * @author James Wilson <jwilson556@gmail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-filter.html
+ */
+class Type extends AbstractFilter
+{
+ /**
+ * Type name.
+ *
+ * @var string
+ */
+ protected $_type = null;
+
+ /**
+ * Construct Type Filter.
+ *
+ * @param string $type Type name
+ */
+ public function __construct($type = null)
+ {
+ if ($type) {
+ $this->setType($type);
+ }
+ }
+
+ /**
+ * Ads a field with arguments to the range query.
+ *
+ * @param string $typeName Type name
+ *
+ * @return $this
+ */
+ public function setType($typeName)
+ {
+ $this->_type = $typeName;
+
+ return $this;
+ }
+
+ /**
+ * Convert object to array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array Filter array
+ */
+ public function toArray()
+ {
+ return array(
+ 'type' => array('value' => $this->_type),
+ );
+ }
+}