File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ public static function factory(array $attributes): IndexInterface
3838 'geo ' => GeoSpatialIndex::class,
3939 'skiplist ' => SkipListIndex::class,
4040 'ttl ' => TTLIndex::class,
41+ 'inverted ' => InvertedIndex::class
4142 ];
4243
4344 if (!array_key_exists ($ attributes ['type ' ], $ indexes )) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ArangoDB \Collection \Index ;
4+
5+ use ArangoDB \Validation \Exceptions \InvalidParameterException ;
6+
7+ /**
8+ * Inverted index representation
9+ *
10+ * @package ArangoDB\Collection\Index
11+ * @author Lucas S. Vieira
12+ */
13+ class InvertedIndex extends Index
14+ {
15+ /**
16+ * InvertedIndex constructor
17+ *
18+ * @param array $fields Fields for which the index applies to
19+ * @param array $attributes Index $attributes
20+ *
21+ * @throws InvalidParameterException
22+ */
23+ public function __construct (array $ fields , array $ attributes = [])
24+ {
25+ parent ::__construct ('inverted ' , $ fields , $ attributes );
26+ }
27+ }
Original file line number Diff line number Diff line change 22
33namespace Unit \Collection \GeneralIndex ;
44
5+ use ArangoDB \Collection \Index \InvertedIndex ;
56use Unit \TestCase ;
67use ArangoDB \Collection \Index \Index ;
78use ArangoDB \Collection \Index \Factory ;
@@ -161,6 +162,21 @@ public function mockGenericArray(): array
161162 ];
162163 }
163164
165+ public function mockInvertedArray (): array
166+ {
167+ return [
168+ 'fields ' => [
169+ 'my_field ' ,
170+ ],
171+ 'id ' => 'coll/0 ' ,
172+ 'name ' => 'inverted_idx ' ,
173+ 'sparse ' => true ,
174+ 'unique ' => false ,
175+ 'type ' => 'inverted ' ,
176+ 'selectivityEstimate ' => 0.015
177+ ];
178+ }
179+
164180 public function testFactoryMakesPrimaryIndex ()
165181 {
166182 $ index = Factory::factory ($ this ->mockPrimaryArray ());
@@ -209,6 +225,12 @@ public function testFactoryMakesTTLIndex()
209225 $ this ->assertInstanceOf (TTLIndex::class, $ index );
210226 }
211227
228+ public function testFactoryMakesInvertedIndex ()
229+ {
230+ $ index = Factory::factory ($ this ->mockInvertedArray ());
231+ $ this ->assertInstanceOf (InvertedIndex::class, $ index );
232+ }
233+
212234 public function testFactoryMakesGenericIndex ()
213235 {
214236 $ this ->expectException (IndexException::class);
You can’t perform that action at this time.
0 commit comments