blob: 1e7bf13299f1818e951af5a910571f6effccf4d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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();
}
}
|