summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-18 06:00:00 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-18 06:00:00 +0100
commit15e69f7b20b6596b9148030acce5b59993b95a45 (patch)
tree7b828b8920b0e222dc2a2c97dde933c9c4864fab /vendor/ruflin/elastica/lib/Elastica/Query/Terms.php
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.25.4
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Query/Terms.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Terms.php103
1 files changed, 103 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php
new file mode 100644
index 00000000..41cc9216
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php
@@ -0,0 +1,103 @@
+<?php
+
+namespace Elastica\Query;
+use Elastica\Exception\InvalidException;
+
+/**
+ * Terms query
+ *
+ * @category Xodoa
+ * @package Elastica
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ * @link http://www.elasticsearch.org/guide/reference/query-dsl/terms-query.html
+ */
+class Terms extends AbstractQuery
+{
+ /**
+ * Terms
+ *
+ * @var array Terms
+ */
+ protected $_terms = array();
+
+ /**
+ * Params
+ *
+ * @var array Params
+ */
+ protected $_params = array();
+
+ /**
+ * Terms key
+ *
+ * @var string Terms key
+ */
+ protected $_key = '';
+
+ /**
+ * Construct terms query
+ *
+ * @param string $key OPTIONAL Terms key
+ * @param array $terms OPTIONAL Terms list
+ */
+ public function __construct($key = '', array $terms = array())
+ {
+ $this->setTerms($key, $terms);
+ }
+
+ /**
+ * Sets key and terms for the query
+ *
+ * @param string $key Terms key
+ * @param array $terms Terms for the query.
+ * @return \Elastica\Query\Terms
+ */
+ public function setTerms($key, array $terms)
+ {
+ $this->_key = $key;
+ $this->_terms = array_values($terms);
+
+ return $this;
+ }
+
+ /**
+ * Adds a single term to the list
+ *
+ * @param string $term Term
+ * @return \Elastica\Query\Terms
+ */
+ public function addTerm($term)
+ {
+ $this->_terms[] = $term;
+
+ return $this;
+ }
+
+ /**
+ * Sets the minimum matching values
+ *
+ * @param int $minimum Minimum value
+ * @return \Elastica\Query\Terms
+ */
+ public function setMinimumMatch($minimum)
+ {
+ return $this->setParam('minimum_match', (int) $minimum);
+ }
+
+ /**
+ * Converts the terms object to an array
+ *
+ * @see \Elastica\Query\AbstractQuery::toArray()
+ * @throws \Elastica\Exception\InvalidException
+ * @return array Query array
+ */
+ public function toArray()
+ {
+ if (empty($this->_key)) {
+ throw new InvalidException('Terms key has to be set');
+ }
+ $this->setParam($this->_key, $this->_terms);
+
+ return parent::toArray();
+ }
+}