| @@ 93-113 (lines=21) @@ | ||
| 90 | ]; |
|
| 91 | } |
|
| 92 | ||
| 93 | protected function _getIndexForTest(): Index |
|
| 94 | { |
|
| 95 | $index = $this->_createIndex(); |
|
| 96 | ||
| 97 | $mapping = new Mapping([ |
|
| 98 | 'color' => ['type' => 'keyword'], |
|
| 99 | ]); |
|
| 100 | $index->setMapping($mapping); |
|
| 101 | ||
| 102 | $index->addDocuments([ |
|
| 103 | new Document(1, ['color' => 'blue']), |
|
| 104 | new Document(2, ['color' => 'blue']), |
|
| 105 | new Document(3, ['color' => 'red']), |
|
| 106 | new Document(4, ['color' => 'green']), |
|
| 107 | new Document(5, ['anything' => 'anything']), |
|
| 108 | ]); |
|
| 109 | ||
| 110 | $index->refresh(); |
|
| 111 | ||
| 112 | return $index; |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| @@ 141-161 (lines=21) @@ | ||
| 138 | $this->assertSame('blue', $results['buckets'][2]['key']); |
|
| 139 | } |
|
| 140 | ||
| 141 | private function getIndex(): Index |
|
| 142 | { |
|
| 143 | $index = $this->_createIndex(); |
|
| 144 | ||
| 145 | $mapping = new Mapping([ |
|
| 146 | 'color' => ['type' => 'keyword'], |
|
| 147 | ]); |
|
| 148 | $index->setMapping($mapping); |
|
| 149 | ||
| 150 | $index->addDocuments([ |
|
| 151 | new Document(1, ['color' => 'blue']), |
|
| 152 | new Document(2, ['color' => 'blue']), |
|
| 153 | new Document(3, ['color' => 'red']), |
|
| 154 | new Document(4, ['color' => 'green']), |
|
| 155 | new Document(5, ['anything' => 'anything']), |
|
| 156 | ]); |
|
| 157 | ||
| 158 | $index->refresh(); |
|
| 159 | ||
| 160 | return $index; |
|
| 161 | } |
|
| 162 | } |
|
| 163 | ||