tests/Aggregation/FiltersTest.php 1 location
|
@@ 230-244 (lines=15) @@
|
| 227 |
|
$this->assertEquals((5 + 8 + 3) / 3, $resultsForOtherBucket['avg_price']['value']); |
| 228 |
|
} |
| 229 |
|
|
| 230 |
|
protected function _getIndexForTest(): Index |
| 231 |
|
{ |
| 232 |
|
$index = $this->_createIndex('filter'); |
| 233 |
|
|
| 234 |
|
$index->addDocuments([ |
| 235 |
|
new Document(1, ['price' => 5, 'color' => 'blue']), |
| 236 |
|
new Document(2, ['price' => 8, 'color' => 'blue']), |
| 237 |
|
new Document(3, ['price' => 1, 'color' => 'red']), |
| 238 |
|
new Document(4, ['price' => 3, 'color' => 'green']), |
| 239 |
|
]); |
| 240 |
|
|
| 241 |
|
$index->refresh(); |
| 242 |
|
|
| 243 |
|
return $index; |
| 244 |
|
} |
| 245 |
|
} |
| 246 |
|
|
tests/Aggregation/FilterTest.php 1 location
|
@@ 103-117 (lines=15) @@
|
| 100 |
|
$this->assertEquals('foo', $agg->getName()); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
protected function _getIndexForTest(): Index |
| 104 |
|
{ |
| 105 |
|
$index = $this->_createIndex(); |
| 106 |
|
|
| 107 |
|
$index->addDocuments([ |
| 108 |
|
new Document(1, ['price' => 5, 'color' => 'blue']), |
| 109 |
|
new Document(2, ['price' => 8, 'color' => 'blue']), |
| 110 |
|
new Document(3, ['price' => 1, 'color' => 'red']), |
| 111 |
|
new Document(4, ['price' => 3, 'color' => 'green']), |
| 112 |
|
]); |
| 113 |
|
|
| 114 |
|
$index->refresh(); |
| 115 |
|
|
| 116 |
|
return $index; |
| 117 |
|
} |
| 118 |
|
} |
| 119 |
|
|
tests/Aggregation/ScriptedMetricTest.php 1 location
|
@@ 37-55 (lines=19) @@
|
| 34 |
|
$this->assertEquals([100, 50, 150], $results['value'][0]); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
protected function _getIndexForTest(): Index |
| 38 |
|
{ |
| 39 |
|
$index = $this->_createIndex(); |
| 40 |
|
|
| 41 |
|
$index->setMapping(new Mapping([ |
| 42 |
|
'start' => ['type' => 'long'], |
| 43 |
|
'end' => ['type' => 'long'], |
| 44 |
|
])); |
| 45 |
|
|
| 46 |
|
$index->addDocuments([ |
| 47 |
|
new Document(1, ['start' => 100, 'end' => 200]), |
| 48 |
|
new Document(2, ['start' => 200, 'end' => 250]), |
| 49 |
|
new Document(3, ['start' => 300, 'end' => 450]), |
| 50 |
|
]); |
| 51 |
|
|
| 52 |
|
$index->refresh(); |
| 53 |
|
|
| 54 |
|
return $index; |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
|
tests/Query/PostFilterTest.php 1 location
|
@@ 52-65 (lines=14) @@
|
| 49 |
|
$this->assertEquals(1, $this->_getTestIndex()->count($query)); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
protected function _getTestIndex() |
| 53 |
|
{ |
| 54 |
|
$index = $this->_createIndex(); |
| 55 |
|
$docs = [ |
| 56 |
|
new Document(1, ['color' => 'green', 'make' => 'ford']), |
| 57 |
|
new Document(2, ['color' => 'blue', 'make' => 'volvo']), |
| 58 |
|
new Document(3, ['color' => 'red', 'make' => 'ford']), |
| 59 |
|
new Document(4, ['color' => 'green', 'make' => 'renault']), |
| 60 |
|
]; |
| 61 |
|
$index->addDocuments($docs); |
| 62 |
|
$index->refresh(); |
| 63 |
|
|
| 64 |
|
return $index; |
| 65 |
|
} |
| 66 |
|
} |
| 67 |
|
|
tests/Aggregation/WeightedAvgTest.php 1 location
|
@@ 86-99 (lines=14) @@
|
| 83 |
|
$agg->setWeight('weight'); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
protected function _getIndexForTest(): Index |
| 87 |
|
{ |
| 88 |
|
$index = $this->_createIndex(); |
| 89 |
|
$index->addDocuments([ |
| 90 |
|
new Document(1, ['price' => 5, 'weight' => 3]), |
| 91 |
|
new Document(2, ['price' => 8, 'weight' => 1]), |
| 92 |
|
new Document(3, ['price' => 1, 'weight' => 1]), |
| 93 |
|
new Document(4, ['price' => 3]), |
| 94 |
|
]); |
| 95 |
|
|
| 96 |
|
$index->refresh(); |
| 97 |
|
|
| 98 |
|
return $index; |
| 99 |
|
} |
| 100 |
|
} |
| 101 |
|
|
tests/Aggregation/CompositeTest.php 1 location
|
@@ 181-195 (lines=15) @@
|
| 178 |
|
$this->assertEquals($expected, $results); |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
protected function _getIndexForTest(): Index |
| 182 |
|
{ |
| 183 |
|
$index = $this->_createIndex(); |
| 184 |
|
|
| 185 |
|
$index->addDocuments([ |
| 186 |
|
new Document(1, ['price' => 5, 'color' => 'blue']), |
| 187 |
|
new Document(2, ['price' => 5, 'color' => 'blue']), |
| 188 |
|
new Document(3, ['price' => 3, 'color' => 'red']), |
| 189 |
|
new Document(4, ['price' => 3, 'color' => 'green']), |
| 190 |
|
]); |
| 191 |
|
|
| 192 |
|
$index->refresh(); |
| 193 |
|
|
| 194 |
|
return $index; |
| 195 |
|
} |
| 196 |
|
} |
| 197 |
|
|