tests/Aggregation/NestedTest.php 1 location
|
@@ 20-33 (lines=14) @@
|
| 17 |
|
/** |
| 18 |
|
* @group functional |
| 19 |
|
*/ |
| 20 |
|
public function testNestedAggregation(): void |
| 21 |
|
{ |
| 22 |
|
$agg = new Nested('resellers', 'resellers'); |
| 23 |
|
$min = new Min('min_price'); |
| 24 |
|
$min->setField('resellers.price'); |
| 25 |
|
$agg->addAggregation($min); |
| 26 |
|
|
| 27 |
|
$query = new Query(); |
| 28 |
|
$query->addAggregation($agg); |
| 29 |
|
|
| 30 |
|
$results = $this->_getIndexForTest()->search($query)->getAggregation('resellers'); |
| 31 |
|
|
| 32 |
|
$this->assertEquals(4.98, $results['min_price']['value']); |
| 33 |
|
} |
| 34 |
|
|
| 35 |
|
protected function _getIndexForTest(): Index |
| 36 |
|
{ |
tests/Aggregation/RangeTest.php 1 location
|
@@ 18-29 (lines=12) @@
|
| 15 |
|
/** |
| 16 |
|
* @group functional |
| 17 |
|
*/ |
| 18 |
|
public function testRangeAggregation(): void |
| 19 |
|
{ |
| 20 |
|
$agg = new Range('range'); |
| 21 |
|
$agg->setField('price'); |
| 22 |
|
$agg->addRange(1.5, 5); |
| 23 |
|
|
| 24 |
|
$query = new Query(); |
| 25 |
|
$query->addAggregation($agg); |
| 26 |
|
$results = $this->_getIndexForTest()->search($query)->getAggregation('range'); |
| 27 |
|
|
| 28 |
|
$this->assertEquals(2, $results['buckets'][0]['doc_count']); |
| 29 |
|
} |
| 30 |
|
|
| 31 |
|
/** |
| 32 |
|
* @group unit |
tests/Aggregation/TermsTest.php 1 location
|
@@ 103-114 (lines=12) @@
|
| 100 |
|
$this->assertEquals('blue', $results['buckets'][0]['key']); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
public function testTermsSetOrder(): void |
| 104 |
|
{ |
| 105 |
|
$agg = new Terms('terms'); |
| 106 |
|
$agg->setField('color'); |
| 107 |
|
$agg->setOrder('_count', 'asc'); |
| 108 |
|
|
| 109 |
|
$query = new Query(); |
| 110 |
|
$query->addAggregation($agg); |
| 111 |
|
$results = $this->getIndex()->search($query)->getAggregation('terms'); |
| 112 |
|
|
| 113 |
|
$this->assertEquals('blue', $results['buckets'][2]['key']); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
public function testTermsSetOrders(): void |
| 117 |
|
{ |