tests/Aggregation/ValueCountTest.php 1 location
|
@@ 29-44 (lines=16) @@
|
| 26 |
|
$this->assertEquals(5, $results['value']); |
| 27 |
|
} |
| 28 |
|
|
| 29 |
|
protected function _getIndexForTest(): Index |
| 30 |
|
{ |
| 31 |
|
$index = $this->_createIndex(); |
| 32 |
|
|
| 33 |
|
$index->addDocuments([ |
| 34 |
|
new Document(1, ['price' => 5]), |
| 35 |
|
new Document(2, ['price' => 8]), |
| 36 |
|
new Document(3, ['price' => 1]), |
| 37 |
|
new Document(4, ['price' => 3]), |
| 38 |
|
new Document(5, ['price' => 3]), |
| 39 |
|
]); |
| 40 |
|
|
| 41 |
|
$index->refresh(); |
| 42 |
|
|
| 43 |
|
return $index; |
| 44 |
|
} |
| 45 |
|
} |
| 46 |
|
|
tests/Suggest/PhraseTest.php 1 location
|
@@ 71-84 (lines=14) @@
|
| 68 |
|
/** |
| 69 |
|
* @return Index |
| 70 |
|
*/ |
| 71 |
|
protected function _getIndexForTest() |
| 72 |
|
{ |
| 73 |
|
$index = $this->_createIndex(); |
| 74 |
|
$index->addDocuments([ |
| 75 |
|
new Document(1, ['text' => 'Github is pretty cool']), |
| 76 |
|
new Document(2, ['text' => 'Elasticsearch is bonsai cool']), |
| 77 |
|
new Document(3, ['text' => 'This is a test phrase']), |
| 78 |
|
new Document(4, ['text' => 'Another sentence for testing']), |
| 79 |
|
new Document(5, ['text' => 'Some more words here']), |
| 80 |
|
]); |
| 81 |
|
$index->refresh(); |
| 82 |
|
|
| 83 |
|
return $index; |
| 84 |
|
} |
| 85 |
|
} |
| 86 |
|
|
tests/Aggregation/AvgTest.php 1 location
|
@@ 52-67 (lines=16) @@
|
| 49 |
|
$this->assertEquals((5 + 8 + 1 + 3 + 72) / 5.0, $results['avg']['value']); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
protected function _getIndexForTest(): Index |
| 53 |
|
{ |
| 54 |
|
$index = $this->_createIndex(); |
| 55 |
|
|
| 56 |
|
$index->addDocuments([ |
| 57 |
|
new Document(1, ['price' => 5]), |
| 58 |
|
new Document(2, ['price' => 8]), |
| 59 |
|
new Document(3, ['price' => 1]), |
| 60 |
|
new Document(4, ['price' => 3]), |
| 61 |
|
new Document(5, ['anything' => 'anything']), |
| 62 |
|
]); |
| 63 |
|
|
| 64 |
|
$index->refresh(); |
| 65 |
|
|
| 66 |
|
return $index; |
| 67 |
|
} |
| 68 |
|
} |
| 69 |
|
|
tests/Aggregation/ExtendedStatsTest.php 1 location
|
@@ 56-71 (lines=16) @@
|
| 53 |
|
$this->assertArrayHasKey('sum_of_squares', $results); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
protected function _getIndexForTest(): Index |
| 57 |
|
{ |
| 58 |
|
$index = $this->_createIndex(); |
| 59 |
|
|
| 60 |
|
$index->addDocuments([ |
| 61 |
|
new Document(1, ['price' => 5]), |
| 62 |
|
new Document(2, ['price' => 8]), |
| 63 |
|
new Document(3, ['price' => 1]), |
| 64 |
|
new Document(4, ['price' => 3]), |
| 65 |
|
new Document(5, ['anything' => 'anything']), |
| 66 |
|
]); |
| 67 |
|
|
| 68 |
|
$index->refresh(); |
| 69 |
|
|
| 70 |
|
return $index; |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
tests/Aggregation/StatsTest.php 1 location
|
@@ 54-69 (lines=16) @@
|
| 51 |
|
$this->assertEquals((5 + 8 + 1 + 3 + 10), $results['sum']); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
protected function _getIndexForTest(): Index |
| 55 |
|
{ |
| 56 |
|
$index = $this->_createIndex(); |
| 57 |
|
|
| 58 |
|
$index->addDocuments([ |
| 59 |
|
new Document(1, ['price' => 5]), |
| 60 |
|
new Document(2, ['price' => 8]), |
| 61 |
|
new Document(3, ['price' => 1]), |
| 62 |
|
new Document(4, ['price' => 3]), |
| 63 |
|
new Document(5, ['anything' => 'anything']), |
| 64 |
|
]); |
| 65 |
|
|
| 66 |
|
$index->refresh(); |
| 67 |
|
|
| 68 |
|
return $index; |
| 69 |
|
} |
| 70 |
|
} |
| 71 |
|
|
tests/Aggregation/SumTest.php 1 location
|
@@ 46-61 (lines=16) @@
|
| 43 |
|
$this->assertEquals(5 + 8 + 1 + 3 + 10, $results['value']); |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
protected function _getIndexForTest(): Index |
| 47 |
|
{ |
| 48 |
|
$index = $this->_createIndex(); |
| 49 |
|
|
| 50 |
|
$index->addDocuments([ |
| 51 |
|
new Document(1, ['price' => 5]), |
| 52 |
|
new Document(2, ['price' => 8]), |
| 53 |
|
new Document(3, ['price' => 1]), |
| 54 |
|
new Document(4, ['price' => 3]), |
| 55 |
|
new Document(5, ['anything' => 'anything']), |
| 56 |
|
]); |
| 57 |
|
|
| 58 |
|
$index->refresh(); |
| 59 |
|
|
| 60 |
|
return $index; |
| 61 |
|
} |
| 62 |
|
} |
| 63 |
|
|
tests/Aggregation/DateHistogramTest.php 1 location
|
@@ 151-168 (lines=18) @@
|
| 148 |
|
$this->assertInstanceOf(DateHistogram::class, $agg->setTimezone('-02:30')); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
protected function _getIndexForTest(): Index |
| 152 |
|
{ |
| 153 |
|
$index = $this->_createIndex(); |
| 154 |
|
$index->setMapping(new Mapping([ |
| 155 |
|
'created' => ['type' => 'date'], |
| 156 |
|
])); |
| 157 |
|
|
| 158 |
|
$index->addDocuments([ |
| 159 |
|
new Document(1, ['created' => '2014-01-29T00:20:00']), |
| 160 |
|
new Document(2, ['created' => '2014-01-29T02:20:00']), |
| 161 |
|
new Document(3, ['created' => '2014-01-29T03:20:00']), |
| 162 |
|
new Document(4, ['anything' => 'anything']), |
| 163 |
|
]); |
| 164 |
|
|
| 165 |
|
$index->refresh(); |
| 166 |
|
|
| 167 |
|
return $index; |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
|
|
tests/Aggregation/DateRangeTest.php 1 location
|
@@ 144-161 (lines=18) @@
|
| 141 |
|
} |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
protected function _getIndexForTest(): Index |
| 145 |
|
{ |
| 146 |
|
$index = $this->_createIndex(); |
| 147 |
|
$index->setMapping(new Mapping([ |
| 148 |
|
'created' => ['type' => 'date', 'format' => 'epoch_millis'], |
| 149 |
|
])); |
| 150 |
|
|
| 151 |
|
$index->addDocuments([ |
| 152 |
|
new Document(1, ['created' => 1390962135000]), |
| 153 |
|
new Document(2, ['created' => 1390965735000]), |
| 154 |
|
new Document(3, ['created' => 1390954935000]), |
| 155 |
|
new Document(4, ['anything' => 'anything']), |
| 156 |
|
]); |
| 157 |
|
|
| 158 |
|
$index->refresh(); |
| 159 |
|
|
| 160 |
|
return $index; |
| 161 |
|
} |
| 162 |
|
} |
| 163 |
|
|