Skip to content

Commit 6f0e33b

Browse files
committed
Merge branch '6.x'
2 parents 197eedd + 9b023dc commit 6f0e33b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+733
-78
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ install:
1212
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz
1313
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
1414
before_script:
15-
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH
15+
- if [ "$GITHUB_COMPOSER_AUTH" ]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi
1616
- composer install --no-interaction --prefer-dist
1717
script:
1818
- wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200
1919
- vendor/bin/phpunit --coverage-clover=coverage.xml
2020
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/ ./
2121
after_script:
22-
- travis_retry bash <(curl -s https://codecov.io/bash)
22+
- travis_retry bash <(curl -s https://codecov.io/bash)

docs/Query/Compound/FunctionScore.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ $queryArray = $search->toArray();
105105
```php
106106
$functionScoreQuery = new FunctionScoreQuery(new MatchAllQuery());
107107
$existsQuery = new ExistsQuery('price');
108-
$functionScoreQuery->addFieldValueFactorFunction('price', 0.5, 'ln', $existsQuery);
108+
$functionScoreQuery->addFieldValueFactorFunction('price', 0.5, 'ln', $existsQuery, 0);
109109

110110
$search = new Search();
111111
$search->addQuery($functionScoreQuery);

src/Aggregation/AbstractAggregation.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ public function __construct($name)
5858

5959
/**
6060
* @param string $field
61+
*
62+
* @return $this
6163
*/
6264
public function setField($field)
6365
{
6466
$this->field = $field;
67+
68+
return $this;
6569
}
6670

6771
/**

src/Aggregation/Bucketing/ChildrenAggregation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ public function __construct($name, $children = null)
5050
}
5151

5252
/**
53-
* Sets children.
54-
*
5553
* @param string $children
54+
*
55+
* @return $this
5656
*/
5757
public function setChildren($children)
5858
{
5959
$this->children = $children;
60+
61+
return $this;
6062
}
6163

6264
/**

src/Aggregation/Bucketing/CompositeAggregation.php

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,21 @@ class CompositeAggregation extends AbstractAggregation
2929
*/
3030
private $sources = [];
3131

32+
/**
33+
* @var int
34+
*/
35+
private $size;
36+
37+
/**
38+
* @var array
39+
*/
40+
private $after;
41+
3242
/**
3343
* Inner aggregations container init.
3444
*
3545
* @param string $name
36-
* @param BuilderInterface[] $sources
46+
* @param AbstractAggregation[] $sources
3747
*/
3848
public function __construct($name, $sources = [])
3949
{
@@ -45,16 +55,20 @@ public function __construct($name, $sources = [])
4555
}
4656

4757
/**
48-
* @param BuilderInterface $agg
58+
* @param AbstractAggregation $agg
4959
*
5060
* @throws \LogicException
5161
*
5262
* @return self
5363
*/
54-
public function addSource(BuilderInterface $agg)
64+
public function addSource(AbstractAggregation $agg)
5565
{
66+
$array = $agg->getArray();
67+
68+
$array = is_array($array) ? array_merge($array, $agg->getParameters()) : $array;
69+
5670
$this->sources[] = [
57-
$agg->getName() => [ $agg->getType() => $agg->getArray() ]
71+
$agg->getName() => [ $agg->getType() => $array ]
5872
];
5973

6074
return $this;
@@ -65,9 +79,19 @@ public function addSource(BuilderInterface $agg)
6579
*/
6680
public function getArray()
6781
{
68-
return [
82+
$array = [
6983
'sources' => $this->sources,
7084
];
85+
86+
if ($this->size !== null) {
87+
$array['size'] = $this->size;
88+
}
89+
90+
if (!empty($this->after)) {
91+
$array['after'] = $this->after;
92+
}
93+
94+
return $array;
7195
}
7296

7397
/**
@@ -77,4 +101,52 @@ public function getType()
77101
{
78102
return 'composite';
79103
}
104+
105+
/**
106+
* Sets size
107+
*
108+
* @param int $size Size
109+
*
110+
* @return $this
111+
*/
112+
public function setSize($size)
113+
{
114+
$this->size = $size;
115+
116+
return $this;
117+
}
118+
119+
/**
120+
* Returns size
121+
*
122+
* @return int
123+
*/
124+
public function getSize()
125+
{
126+
return $this->size;
127+
}
128+
129+
/**
130+
* Sets after
131+
*
132+
* @param array $after After
133+
*
134+
* @return $this
135+
*/
136+
public function setAfter(array $after)
137+
{
138+
$this->after = $after;
139+
140+
return $this;
141+
}
142+
143+
/**
144+
* Returns after
145+
*
146+
* @return array
147+
*/
148+
public function getAfter()
149+
{
150+
return $this->after;
151+
}
80152
}

src/Aggregation/Bucketing/DateHistogramAggregation.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,26 @@ public function getInterval()
5959

6060
/**
6161
* @param string $interval
62+
*
63+
* @return $this
6264
*/
6365
public function setInterval($interval)
6466
{
6567
$this->interval = $interval;
68+
69+
return $this;
6670
}
6771

6872
/**
6973
* @param string $format
74+
*
75+
* @return $this
7076
*/
7177
public function setFormat($format)
7278
{
7379
$this->format = $format;
80+
81+
return $this;
7482
}
7583

7684
/**

src/Aggregation/Bucketing/DateRangeAggregation.php

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,29 @@ class DateRangeAggregation extends AbstractAggregation
2929
private $format;
3030

3131
/**
32-
* @return string
32+
* @var array
3333
*/
34-
public function getFormat()
35-
{
36-
return $this->format;
37-
}
34+
private $ranges = [];
35+
36+
/**
37+
* @var bool
38+
*/
39+
private $keyed = false;
3840

3941
/**
4042
* @param string $name
4143
* @param string $field
4244
* @param string $format
4345
* @param array $ranges
46+
* @param bool $keyed
4447
*/
45-
public function __construct($name, $field = null, $format = null, array $ranges = [])
48+
public function __construct($name, $field = null, $format = null, array $ranges = [], $keyed = false)
4649
{
4750
parent::__construct($name);
4851

4952
$this->setField($field);
5053
$this->setFormat($format);
54+
$this->setKeyed($keyed);
5155
foreach ($ranges as $range) {
5256
$from = isset($range['from']) ? $range['from'] : null;
5357
$to = isset($range['to']) ? $range['to'] : null;
@@ -57,23 +61,41 @@ public function __construct($name, $field = null, $format = null, array $ranges
5761
}
5862

5963
/**
60-
* @param string $format
64+
* Sets if result buckets should be keyed.
65+
*
66+
* @param bool $keyed
67+
*
68+
* @return DateRangeAggregation
6169
*/
62-
public function setFormat($format)
70+
public function setKeyed($keyed)
6371
{
64-
$this->format = $format;
72+
$this->keyed = $keyed;
73+
74+
return $this;
6575
}
6676

6777
/**
68-
* @var array
78+
* @return string
6979
*/
70-
private $ranges = [];
80+
public function getFormat()
81+
{
82+
return $this->format;
83+
}
84+
85+
/**
86+
* @param string $format
87+
*/
88+
public function setFormat($format)
89+
{
90+
$this->format = $format;
91+
}
7192

7293
/**
7394
* Add range to aggregation.
7495
*
7596
* @param string|null $from
7697
* @param string|null $to
98+
* @param string|null $key
7799
*
78100
* @return $this
79101
*
@@ -111,6 +133,7 @@ public function getArray()
111133
'format' => $this->getFormat(),
112134
'field' => $this->getField(),
113135
'ranges' => $this->ranges,
136+
'keyed' => $this->keyed,
114137
];
115138

116139
return $data;

src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ public function getShardSize()
5454

5555
/**
5656
* @param mixed $shardSize
57+
*
58+
* @return $this
5759
*/
5860
public function setShardSize($shardSize)
5961
{
6062
$this->shardSize = $shardSize;
63+
64+
return $this;
6165
}
6266

6367
/**

src/Aggregation/Bucketing/FilterAggregation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ public function __construct($name, BuilderInterface $filter = null)
4545
}
4646

4747
/**
48-
* Sets a filter.
49-
*
5048
* @param BuilderInterface $filter
49+
*
50+
* @return $this
5151
*/
5252
public function setFilter(BuilderInterface $filter)
5353
{
5454
$this->filter = $filter;
55+
56+
return $this;
5557
}
5658

5759
/**

src/Aggregation/Bucketing/FiltersAggregation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct($name, $filters = [], $anonymous = false)
5858
/**
5959
* @param bool $anonymous
6060
*
61-
* @return FiltersAggregation
61+
* @return $this
6262
*/
6363
public function setAnonymous($anonymous)
6464
{

0 commit comments

Comments
 (0)