| @@ 36-54 (lines=19) @@ | ||
| 33 | /** |
|
| 34 | * @group functional |
|
| 35 | */ |
|
| 36 | public function testHistogramKeyedAggregation(): void |
|
| 37 | { |
|
| 38 | $agg = new Histogram('hist', 'price', 10); |
|
| 39 | $agg->setMinimumDocumentCount(0); // should return empty buckets |
|
| 40 | $agg->setKeyed(); |
|
| 41 | ||
| 42 | $query = new Query(); |
|
| 43 | $query->addAggregation($agg); |
|
| 44 | $results = $this->_getIndexForTest()->search($query)->getAggregation('hist'); |
|
| 45 | ||
| 46 | $expected = [ |
|
| 47 | '0.0', |
|
| 48 | '10.0', |
|
| 49 | '20.0', |
|
| 50 | '30.0', |
|
| 51 | '40.0', |
|
| 52 | ]; |
|
| 53 | $this->assertSame($expected, \array_keys($results['buckets'])); |
|
| 54 | } |
|
| 55 | ||
| 56 | protected function _getIndexForTest(): Index |
|
| 57 | { |
|
| @@ 113-129 (lines=17) @@ | ||
| 110 | /** |
|
| 111 | * @group functional |
|
| 112 | */ |
|
| 113 | public function testDateHistogramKeyedAggregation(): void |
|
| 114 | { |
|
| 115 | $agg = new DateHistogram('hist', 'created', '1h'); |
|
| 116 | $agg->setKeyed(); |
|
| 117 | ||
| 118 | $query = new Query(); |
|
| 119 | $query->addAggregation($agg); |
|
| 120 | $results = $this->_getIndexForTest()->search($query)->getAggregation('hist'); |
|
| 121 | ||
| 122 | $expected = [ |
|
| 123 | '2014-01-29T00:00:00.000Z', |
|
| 124 | '2014-01-29T01:00:00.000Z', |
|
| 125 | '2014-01-29T02:00:00.000Z', |
|
| 126 | '2014-01-29T03:00:00.000Z', |
|
| 127 | ]; |
|
| 128 | $this->assertSame($expected, \array_keys($results['buckets'])); |
|
| 129 | } |
|
| 130 | ||
| 131 | /** |
|
| 132 | * @group unit |
|