summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php')
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php75
1 files changed, 46 insertions, 29 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
index 2f7c88e3..c099ab3d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
@@ -1,42 +1,40 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Exception\InvalidException;
/**
- * Terms filter
+ * Terms filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
*/
class Terms extends AbstractFilter
{
/**
- * Terms
+ * Terms.
*
* @var array Terms
*/
protected $_terms = array();
/**
- * Params
+ * Params.
*
* @var array Params
*/
protected $_params = array();
/**
- * Terms key
+ * Terms key.
*
* @var string Terms key
*/
protected $_key = '';
/**
- * Creates terms filter
+ * Creates terms filter.
*
* @param string $key Terms key
* @param array $terms Terms values
@@ -47,11 +45,12 @@ class Terms extends AbstractFilter
}
/**
- * Sets key and terms for the filter
+ * Sets key and terms for the filter.
*
- * @param string $key Terms key
- * @param array $terms Terms for the query.
- * @return \Elastica\Filter\Terms
+ * @param string $key Terms key
+ * @param array $terms Terms for the query.
+ *
+ * @return $this
*/
public function setTerms($key, array $terms)
{
@@ -62,13 +61,15 @@ class Terms extends AbstractFilter
}
/**
- * 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
+ * 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
+ *
+ * @return $this
*/
public function setLookup($key, $type, $id, $path, $options = array())
{
@@ -79,32 +80,34 @@ class Terms extends AbstractFilter
$this->_terms = array(
'type' => $type,
'id' => $id,
- 'path' => $path
+ 'path' => $path,
);
-
+
$index = $options;
- if(is_array($options)) {
- if(isset($options['index'])) {
+ 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
+ * Adds an additional term to the query.
+ *
+ * @param string $term Filter term
*
- * @param string $term Filter term
- * @return \Elastica\Filter\Terms Filter object
+ * @return $this
*/
public function addTerm($term)
{
@@ -114,11 +117,13 @@ class Terms extends AbstractFilter
}
/**
- * Converts object to an array
+ * Converts object to an array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @throws \Elastica\Exception\InvalidException
- * @return array data array
+ *
+ * @return array
*/
public function toArray()
{
@@ -129,4 +134,16 @@ class Terms extends AbstractFilter
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);
+ }
}