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.php57
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php190
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php50
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php77
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php146
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php43
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php35
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php49
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php73
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php101
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php59
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php85
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php74
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php45
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php78
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php77
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php92
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php51
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php36
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php37
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php60
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php15
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php79
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Query.php90
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Range.php61
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php80
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Script.php49
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Term.php47
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php132
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Type.php60
33 files changed, 2194 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..665f155f
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+use Elastica\Param;
+
+/**
+ * Abstract filter object. Should be extended by all filter types
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/
+ */
+abstract class AbstractFilter extends Param
+{
+ /**
+ * Sets the filter cache
+ *
+ * @param boolean $cached Cached
+ * @return \Elastica\Filter\AbstractFilter
+ */
+ 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
+ * @return \Elastica\Filter\AbstractFilter
+ */
+ 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 \Elastica\Filter\AbstractFilter
+ */
+ 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..997ceab7
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php
@@ -0,0 +1,190 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Geo distance filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\AbstractGeoDistance current filter
+ */
+ public function setKey($key)
+ {
+ $this->_key = $key;
+
+ return $this;
+ }
+
+ /**
+ * @param array|string $location
+ * @return \Elastica\Filter\AbstractGeoDistance
+ * @throws \Elastica\Exception\InvalidException
+ */
+ 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 \Elastica\Filter\AbstractGeoDistance current filter
+ */
+ public function setLatitude($latitude)
+ {
+ $this->_latitude = (float) $latitude;
+ $this->_locationType = self::LOCATION_TYPE_LATLON;
+
+ return $this;
+ }
+
+ /**
+ * @param float $longitude
+ * @return \Elastica\Filter\AbstractGeoDistance current filter
+ */
+ public function setLongitude($longitude)
+ {
+ $this->_longitude = (float) $longitude;
+ $this->_locationType = self::LOCATION_TYPE_LATLON;
+
+ return $this;
+ }
+
+ /**
+ * @param string $geohash
+ * @return \Elastica\Filter\AbstractGeoDistance current filter
+ */
+ public function setGeohash($geohash)
+ {
+ $this->_geohash = $geohash;
+ $this->_locationType = self::LOCATION_TYPE_GEOHASH;
+
+ return $this;
+ }
+
+ /**
+ * @return array|string
+ * @throws \Elastica\Exception\InvalidException
+ */
+ 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
+ */
+ 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..3585293b
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * geo_shape filter
+ *
+ * Filter pre-indexed shape definitions
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Bennie Krijger <benniekrijger@gmail.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-shape-filter/
+ */
+abstract class AbstractGeoShape extends AbstractFilter
+{
+ const RELATION_INTERSECT = 'intersects';
+ const RELATION_DISJOINT = 'disjoint';
+ const RELATION_CONTAINS = 'within';
+
+ /**
+ * @var string $_path
+ *
+ * elasticsearch path of the pre-indexed shape
+ */
+ protected $_path;
+
+ /**
+ * @var string $_relation
+ *
+ * the relation of the 2 shaped: intersects, disjoint, within
+ */
+ protected $_relation = self::RELATION_INTERSECT;
+
+ /**
+ * @param string $relation
+ */
+ public function setRelation($relation)
+ {
+ $this->_relation = $relation;
+ }
+
+ /**
+ * @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..53ef74cf
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php
@@ -0,0 +1,77 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Multi Abstract filter object. Should be extended by filter types composed of an array of sub filters
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ */
+abstract class AbstractMulti extends AbstractFilter
+{
+ /**
+ * Filters
+ * @var array
+ */
+ protected $_filters = array();
+
+ /**
+ * Add filter
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ * @return \Elastica\Filter\AbstractMulti
+ */
+ public function addFilter(AbstractFilter $filter)
+ {
+ $this->_filters[] = $filter->toArray();
+
+ return $this;
+ }
+
+ /**
+ * Set filters
+ *
+ * @param array $filters
+ * @return \Elastica\Filter\AbstractMulti
+ */
+ 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()
+ */
+ 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..aff708f8
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php
@@ -0,0 +1,146 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Bool Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
+ */
+class Bool extends AbstractFilter
+{
+ /**
+ * @var float
+ */
+ protected $_boost = 1.0;
+
+ /**
+ * 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 \Elastica\Filter\Bool Current object
+ */
+ public function addShould($args)
+ {
+ return $this->_addFilter('should', $args);
+ }
+
+ /**
+ * Adds must filter
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ * @return \Elastica\Filter\Bool Current object
+ */
+ public function addMust($args)
+ {
+ return $this->_addFilter('must', $args);
+ }
+
+ /**
+ * Adds mustNot filter
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ * @return \Elastica\Filter\Bool Current object
+ */
+ 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 \Elastica\Filter\Bool Current object
+ */
+ protected function _addFilter($type, $args)
+ {
+ if ($args instanceof AbstractFilter) {
+ $args = $args->toArray();
+ }
+ else if (!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;
+ }
+
+ return $args;
+ }
+
+ /**
+ * Sets the boost value for this filter
+ *
+ * @param float $boost Boost
+ * @return \Elastica\Filter\Bool Current object
+ */
+ public function setBoost($boost)
+ {
+ $this->_boost = $boost;
+
+ return $this;
+ }
+
+}
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..2fd19f8e
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * And Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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/BoolNot.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php
new file mode 100644
index 00000000..1778997b
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Not Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\BoolNot
+ */
+ 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..6f63fc30
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Or Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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..6fe43e3d
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Exists query
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Oleg Cherniy <oleg.cherniy@gmail.com>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\Exists
+ */
+ 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..1462e9af
--- /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
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Fabian Vogler <fabian@equivalence.ch>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\GeoBoundingBox Current object
+ */
+ 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..8e875365
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Geo distance filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-filter.html
+ */
+class GeoDistance extends AbstractGeoDistance
+{
+ const DISTANCE_TYPE_ARC = 'arc';
+ const DISTANCE_TYPE_PLANE = 'plane';
+
+ 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 \Elastica\Filter\GeoDistance current filter
+ */
+ public function setDistance($distance)
+ {
+ $this->setParam('distance', $distance);
+
+ return $this;
+ }
+
+ /**
+ * See DISTANCE_TYPE_* constants
+ *
+ * @param string $distanceType
+ * @return \Elastica\Filter\GeoDistance current filter
+ */
+ public function setDistanceType($distanceType)
+ {
+ $this->setParam('distance_type', $distanceType);
+
+ return $this;
+ }
+
+ /**
+ * See OPTIMIZE_BBOX_* constants
+ *
+ * @param string $optimizeBbox
+ * @return \Elastica\Filter\GeoDistance current filter
+ */
+ 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..230e5ebf
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php
@@ -0,0 +1,101 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Geo distance filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author munkie
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\GeoDistanceRange
+ */
+ 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
+ * @return \Elastica\Filter\GeoDistanceRange
+ * @throws \Elastica\Exception\InvalidException
+ */
+ 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..fa12c035
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Filter\AbstractFilter;
+
+/**
+ * Geo polygon filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Michael Maclean <mgdm@php.net>
+ * @link http://www.elasticsearch.org/guide/reference/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..7e89f8a8
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php
@@ -0,0 +1,85 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * geo_shape filter for pre-indexed shapes
+ *
+ * Filter pre-indexed shape definitions
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Bennie Krijger <benniekrijger@gmail.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-shape-filter/
+ */
+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..5a88c05f
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * geo_shape filter or provided shapes
+ *
+ * Filter provided shape definitions
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author BennieKrijger <benniekrijger@gmail.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-shape-filter/
+ */
+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..d14b25fe
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Elastica\Filter;
+
+
+/**
+ * Class GeohashCell
+ * @package Elastica
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/geohash-cell-filter/
+ */
+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 $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 \Elastica\Filter\GeohashCell
+ */
+ 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 \Elastica\Filter\GeohashCell
+ */
+ public function setNeighbors($neighbors)
+ {
+ return $this->setParam('neighbors', (bool)$neighbors);
+ }
+} \ No newline at end of file
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..e8c6ab96
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
@@ -0,0 +1,78 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Returns parent documents having child docs matching the query
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Fabian Vogler <fabian@equivalence.ch>
+ * @link http://www.elasticsearch.org/guide/reference/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 $type Parent 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 \Elastica\Filter\HasChild Current object
+ */
+ 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 \Elastica\Filter\HasChild Current object
+ */
+ public function setFilter($filter)
+ {
+ $data = $filter->toArray();
+ return $this->setParam('filter', $data);
+ }
+
+ /**
+ * Set type of the parent document
+ *
+ * @param string $type Parent document type
+ * @return \Elastica\Filter\HasChild Current object
+ */
+ public function setType($type)
+ {
+ return $this->setParam('type', $type);
+ }
+
+ /**
+ * Sets the scope
+ *
+ * @param string $scope Scope
+ * @return \Elastica\Filter\HasChild Current object
+ */
+ public function setScope($scope)
+ {
+ return $this->setParam('_scope', $scope);
+ }
+}
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..de49e470
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php
@@ -0,0 +1,77 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Returns child documents having parent docs matching the query
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @link http://www.elasticsearch.org/guide/reference/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 $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 \Elastica\Filter\HasParent Current object
+ */
+ public function setQuery($query)
+ {
+ $query = \Elastica\Query::create($query);
+ $data = $query->toArray();
+
+ return $this->setParam('query', $data['query']);
+ }
+
+ /**
+ * Sets query object
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ * @return \Elastica\Filter\HasParent Current object
+ */
+ public function setFilter($filter)
+ {
+ $data = $filter->toArray();
+ return $this->setParam('filter', $data);
+ }
+
+ /**
+ * Set type of the parent document
+ *
+ * @param string $type Parent document type
+ * @return \Elastica\Filter\HasParent Current object
+ */
+ public function setType($type)
+ {
+ return $this->setParam('type', $type);
+ }
+
+ /**
+ * Sets the scope
+ *
+ * @param string $scope Scope
+ * @return \Elastica\Filter\HasParent Current object
+ */
+ public function setScope($scope)
+ {
+ return $this->setParam('_scope', $scope);
+ }
+}
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..fd1d9770
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php
@@ -0,0 +1,92 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Type as ElasticaType;
+
+/**
+ * Ids Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\Ids Current object
+ */
+ 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 \Elastica\Filter\Ids Current object
+ */
+ 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 \Elastica\Filter\Ids Current object
+ */
+ 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 \Elastica\Filter\Ids Current object
+ */
+ 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..66ca5965
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Elastica\Filter;
+
+
+/**
+ * Class Indices
+ * @package Elastica\Filter
+ * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/query-dsl-indices-filter.html
+ */
+class Indices extends AbstractFilter
+{
+ /**
+ * @param AbstractFilter $filter filter which will be applied to docs in the specified indices
+ * @param string[] $indices
+ */
+ public function __construct(AbstractFilter $filter, array $indices)
+ {
+ $this->setIndices($indices)->setFilter($filter);
+ }
+
+ /**
+ * Set the names of the indices on which this filter should be applied
+ * @param string[] $indices
+ * @return Indices
+ */
+ public function setIndices(array $indices)
+ {
+ return $this->setParam('indices', $indices);
+ }
+
+ /**
+ * Set the filter to be applied to docs in the specified indices
+ * @param AbstractFilter $filter
+ * @return Indices
+ */
+ 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 Indices
+ */
+ public function setNoMatchFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('no_match_filter', $filter->toArray());
+ }
+} \ No newline at end of file
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..e02853ae
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Limit Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/limit-filter.html
+ */
+class Limit extends AbstractFilter
+{
+ /**
+ * Construct limit filter
+ *
+ * @param int $limit Limit
+ * @return \Elastica\Filter\Limit
+ */
+ public function __construct($limit)
+ {
+ $this->setLimit($limit);
+ }
+
+ /**
+ * Set the limit
+ *
+ * @param int $limit Limit
+ * @return \Elastica\Filter\Limit
+ */
+ 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..a69b65a2
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Match all filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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..df8466a8
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Missing Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Maciej Wiercinski <maciej@wiercinski.net>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\Missing
+ */
+ public function setField($field)
+ {
+ return $this->setParam('field', (string) $field);
+ }
+}
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..16293519
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Query\AbstractQuery;
+
+/**
+ * Nested filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter.html
+ */
+class Nested extends AbstractFilter
+{
+ /**
+ * Adds field to mlt filter
+ *
+ * @param string $path Nested object path
+ * @return \Elastica\Filter\Nested
+ */
+ public function setPath($path)
+ {
+ return $this->setParam('path', $path);
+ }
+
+ /**
+ * Sets nested query
+ *
+ * @param \Elastica\Query\AbstractQuery $query
+ * @return \Elastica\Filter\Nested
+ */
+ public function setQuery(AbstractQuery $query)
+ {
+ return $this->setParam('query', $query->toArray());
+ }
+
+ /**
+ * Sets nested filter
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
+ * @return \Elastica\Filter\Nested
+ */
+ public function setFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('filter', $filter->toArray());
+ }
+
+ /**
+ * Set score mode
+ *
+ * @param string $scoreMode Options: avg, total, max and none.
+ * @return \Elastica\Filter\Nested
+ */
+ public function setScoreMode($scoreMode)
+ {
+ return $this->setParam('score_mode', $scoreMode);
+ }
+}
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..5a6e2551
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Numeric Range Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/numeric-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..2caf13cb
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Prefix filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Jasper van Wanrooy <jasper@vanwanrooy.net>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\Prefix
+ */
+ public function setField($field)
+ {
+ $this->_field = $field;
+
+ return $this;
+ }
+
+ /**
+ * Sets the prefix string.
+ *
+ * @param string $prefix Prefix string
+ * @return \Elastica\Filter\Prefix
+ */
+ 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..3f1ba2d2
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php
@@ -0,0 +1,90 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+use Elastica\Query\AbstractQuery;
+
+/**
+ * Query filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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
+ * @return \Elastica\Filter\Query Query object
+ * @throws \Elastica\Exception\InvalidException Invalid param
+ */
+ 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..b142e674
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Range Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/range-filter.html
+ */
+class Range extends AbstractFilter
+{
+ /**
+ * Fields
+ *
+ * @var array Fields
+ */
+ protected $_fields = array();
+
+ /**
+ * Construct range filter
+ *
+ * @param string|bool $fieldName Field name
+ * @param array $args Field arguments
+ */
+ public function __construct($fieldName = false, 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 \Elastica\Filter\Range
+ */
+ public function addField($fieldName, array $args)
+ {
+ $this->_fields[$fieldName] = $args;
+
+ return $this;
+ }
+
+ /**
+ * Converts object to array
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ * @return array Filter array
+ */
+ public function toArray()
+ {
+ $this->setParams($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..33c47cfd
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Regexp filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Timothy Lamb <trash80@gmail.com>
+ * @link http://www.elasticsearch.org/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 = '';
+
+ /**
+ * Create Regexp object
+ *
+ * @param string $field Field name
+ * @param string $regexp Regular expression
+ * @throws \Elastica\Exception\InvalidException
+ */
+ public function __construct($field = '', $regexp = '')
+ {
+ $this->setField($field);
+ $this->setRegexp($regexp);
+ }
+
+ /**
+ * Sets the name of the regexp field.
+ *
+ * @param string $field Field name
+ * @return \Elastica\Filter\Regexp
+ */
+ public function setField($field)
+ {
+ $this->_field = $field;
+
+ return $this;
+ }
+
+ /**
+ * Sets the regular expression query string.
+ *
+ * @param string $regexp Regular expression
+ * @return \Elastica\Filter\Regexp
+ */
+ public function setRegexp($regexp)
+ {
+ $this->_regexp = $regexp;
+
+ return $this;
+ }
+
+ /**
+ * Converts object to an array
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ * @return array data array
+ */
+ public function toArray()
+ {
+ $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..9b34b1ec
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica;
+use Elastica\Query\AbstractQuery;
+
+/**
+ * Script filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\Script
+ */
+ 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..b4773030
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Term query
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\Term Filter object
+ */
+ 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 \Elastica\Filter\Term Filter object
+ */
+ 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..2f7c88e3
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
@@ -0,0 +1,132 @@
+<?php
+
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Terms filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/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 \Elastica\Filter\Terms
+ */
+ 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 \Elastica\Filter\Terms Filter object
+ */
+ 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 \Elastica\Filter\Terms Filter object
+ */
+ 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 data 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);
+ }
+}
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..8fb58c7d
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Elastica\Filter;
+
+/**
+ * Type Filter
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author James Wilson <jwilson556@gmail.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/type-filter.html
+ */
+class Type extends AbstractFilter
+{
+ /**
+ * Type name
+ *
+ * @var string
+ */
+ protected $_type = null;
+
+ /**
+ * Construct Type Filter
+ *
+ * @param string $typeName Type name
+ * @return \Elastica\Filter\Type
+ */
+ public function __construct($typeName = null)
+ {
+ if ($typeName) {
+ $this->setType($typeName);
+ }
+ }
+
+ /**
+ * Ads a field with arguments to the range query
+ *
+ * @param string $typeName Type name
+ * @return \Elastica\Filter\Type current object
+ */
+ 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)
+ );
+ }
+}