| @@ 33-49 (lines=17) @@ | ||
| 30 | $this->assertEquals(-117.24664804526, $results['bounds']['bottom_right']['lon']); |
|
| 31 | } |
|
| 32 | ||
| 33 | private function getIndexForTest(): Index |
|
| 34 | { |
|
| 35 | $index = $this->_createIndex(); |
|
| 36 | $index->setMapping(new Mapping([ |
|
| 37 | 'location' => ['type' => 'geo_point'], |
|
| 38 | ])); |
|
| 39 | ||
| 40 | $index->addDocuments([ |
|
| 41 | new Document(1, ['location' => ['lat' => 32.849437, 'lon' => -117.271732]]), |
|
| 42 | new Document(2, ['location' => ['lat' => 32.798320, 'lon' => -117.246648]]), |
|
| 43 | new Document(3, ['location' => ['lat' => 37.782439, 'lon' => -122.392560]]), |
|
| 44 | ]); |
|
| 45 | ||
| 46 | $index->refresh(); |
|
| 47 | ||
| 48 | return $index; |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 30-46 (lines=17) @@ | ||
| 27 | $this->assertEquals(3, $results['count']); |
|
| 28 | } |
|
| 29 | ||
| 30 | protected function _getIndexForTest(): Index |
|
| 31 | { |
|
| 32 | $index = $this->_createIndex(); |
|
| 33 | $index->setMapping(new Mapping([ |
|
| 34 | 'location' => ['type' => 'geo_point'], |
|
| 35 | ])); |
|
| 36 | ||
| 37 | $index->addDocuments([ |
|
| 38 | new Document(1, ['location' => ['lat' => 32.849437, 'lon' => -117.271732]]), |
|
| 39 | new Document(2, ['location' => ['lat' => 32.798320, 'lon' => -117.246648]]), |
|
| 40 | new Document(3, ['location' => ['lat' => 37.782439, 'lon' => -122.392560]]), |
|
| 41 | ]); |
|
| 42 | ||
| 43 | $index->refresh(); |
|
| 44 | ||
| 45 | return $index; |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| @@ 52-68 (lines=17) @@ | ||
| 49 | $this->assertSame($expected, \array_keys($results['buckets'])); |
|
| 50 | } |
|
| 51 | ||
| 52 | protected function _getIndexForTest(): Index |
|
| 53 | { |
|
| 54 | $index = $this->_createIndex(); |
|
| 55 | $index->setMapping(new Mapping([ |
|
| 56 | 'location' => ['type' => 'geo_point'], |
|
| 57 | ])); |
|
| 58 | ||
| 59 | $index->addDocuments([ |
|
| 60 | new Document(1, ['location' => ['lat' => 32.849437, 'lon' => -117.271732]]), |
|
| 61 | new Document(2, ['location' => ['lat' => 32.798320, 'lon' => -117.246648]]), |
|
| 62 | new Document(3, ['location' => ['lat' => 37.782439, 'lon' => -122.392560]]), |
|
| 63 | ]); |
|
| 64 | ||
| 65 | $index->refresh(); |
|
| 66 | ||
| 67 | return $index; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| @@ 63-79 (lines=17) @@ | ||
| 60 | $this->_createIndex()->search($query)->getAggregation('hash'); |
|
| 61 | } |
|
| 62 | ||
| 63 | protected function _getIndexForTest(): Index |
|
| 64 | { |
|
| 65 | $index = $this->_createIndex(); |
|
| 66 | $index->setMapping(new Mapping([ |
|
| 67 | 'location' => ['type' => 'geo_point'], |
|
| 68 | ])); |
|
| 69 | ||
| 70 | $index->addDocuments([ |
|
| 71 | new Document(1, ['location' => ['lat' => 32.849437, 'lon' => -117.271732]]), |
|
| 72 | new Document(2, ['location' => ['lat' => 32.798320, 'lon' => -117.246648]]), |
|
| 73 | new Document(3, ['location' => ['lat' => 37.782439, 'lon' => -122.392560]]), |
|
| 74 | ]); |
|
| 75 | ||
| 76 | $index->refresh(); |
|
| 77 | ||
| 78 | return $index; |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||