Skip to content

Commit b36e967

Browse files
committed
[DE-104]: deprecate skiplist and hash indexes
1 parent fc982e5 commit b36e967

File tree

5 files changed

+45
-23
lines changed

5 files changed

+45
-23
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## Release notes for the ArangoDB-PHP driver 3.10.x
4+
5+
Using the index types "hash", "skiplist" or "fulltext" is deprecated.
6+
With the RocksDB storage engine, "hash" and "skiplist" indexes are mere aliases of
7+
the "persistent" index type. Thus the "persistent" index is the preferred type to
8+
use from the PHP driver as well.
9+
10+
ArangoDB 3.10 also deprecates the usage of fulltext indexes, so using the "fulltext"
11+
index type from the PHP driver is also deprecated.
12+
313
## Release notes for the ArangoDB-PHP driver 3.9.x
414

515
This version of the PHP driver is compatible with PHP versions 7.4 and 8.0.

lib/ArangoDBClient/CollectionHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ class CollectionHandler extends Handler
144144

145145
/**
146146
* hash index option
147+
* @deprecated "hash" is now an alias for "persistent". use "persistent" instead
147148
*/
148149
const OPTION_HASH_INDEX = 'hash';
149150

150151
/**
151152
* fulltext index option
153+
* @deprecated fulltext indexes are deprecated from ArangoDB 3.10 onwards
152154
*/
153155
const OPTION_FULLTEXT_INDEX = 'fulltext';
154156

@@ -159,6 +161,7 @@ class CollectionHandler extends Handler
159161

160162
/**
161163
* skiplist index option
164+
* @deprecated "skiplist" is now an alias for "persistent". use "persistent" instead
162165
*/
163166
const OPTION_SKIPLIST_INDEX = 'skiplist';
164167

@@ -897,7 +900,7 @@ public function createHashIndex($collection, array $fields, $unique = null, $spa
897900
* @param int $minLength - the minimum length of words to index
898901
* @param bool $inBackground - true if index shall be created in background
899902
*
900-
* @deprecated use CollectionHandler::createIndex instead
903+
* @deprecated use CollectionHandler::createIndex instead. additionally, fulltext indexes are deprecated from ArangoDB 3.10 onwards
901904
*
902905
* @return array - server response of the created index
903906
* @throws \ArangoDBClient\Exception

tests/.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/CollectionBasicTest.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,8 @@ public function testCreateIndex()
790790
{
791791
$result = $this->collectionHandler->createIndex(
792792
'ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp, [
793-
'type' => 'hash',
794-
'name' => 'mr-hash',
793+
'type' => 'persistent',
794+
'name' => 'mr-persistent',
795795
'fields' => ['a', 'b'],
796796
'unique' => true,
797797
'sparse' => true,
@@ -807,11 +807,11 @@ public function testCreateIndex()
807807

808808
$indexInfo = $indicesByIdentifiers[$result['id']];
809809

810-
static::assertEquals('hash', $indexInfo[CollectionHandler::OPTION_TYPE]);
810+
static::assertEquals('persistent', $indexInfo[CollectionHandler::OPTION_TYPE]);
811811
static::assertEquals(['a', 'b'], $indexInfo['fields']);
812812
static::assertTrue($indexInfo['unique']);
813813
static::assertTrue($indexInfo['sparse']);
814-
static::assertEquals('mr-hash', $indexInfo['name']);
814+
static::assertEquals('mr-persistent', $indexInfo['name']);
815815
}
816816

817817

@@ -848,20 +848,18 @@ public function testGetIndexByName()
848848
{
849849
$result = $this->collectionHandler->createIndex(
850850
'ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp, [
851-
'type' => 'fulltext',
851+
'type' => 'persistent',
852852
'name' => 'this-is-an-index',
853853
'fields' => ['c'],
854-
'minLength' => 4,
855854
]
856855
);
857856

858857
$indexInfo = $this->collectionHandler->getIndex('ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp, $result['id']);
859858

860-
static::assertEquals('fulltext', $indexInfo[CollectionHandler::OPTION_TYPE]);
859+
static::assertEquals('persistent', $indexInfo[CollectionHandler::OPTION_TYPE]);
861860
static::assertEquals(['c'], $indexInfo['fields']);
862861
static::assertFalse($indexInfo['unique']);
863-
static::assertTrue($indexInfo['sparse']);
864-
static::assertEquals(4, $indexInfo['minLength']);
862+
static::assertFalse($indexInfo['sparse']);
865863
static::assertEquals('this-is-an-index', $indexInfo['name']);
866864
}
867865

@@ -872,10 +870,9 @@ public function testDropIndexById()
872870
{
873871
$result = $this->collectionHandler->createIndex(
874872
'ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp, [
875-
'type' => 'fulltext',
873+
'type' => 'persistent',
876874
'name' => 'this-is-an-index',
877875
'fields' => ['c'],
878-
'minLength' => 4,
879876
]
880877
);
881878

@@ -891,10 +888,9 @@ public function testDropIndexByName()
891888
{
892889
$result = $this->collectionHandler->createIndex(
893890
'ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp, [
894-
'type' => 'fulltext',
891+
'type' => 'persistent',
895892
'name' => 'this-is-an-index',
896893
'fields' => ['c'],
897-
'minLength' => 4,
898894
]
899895
);
900896

@@ -960,6 +956,7 @@ public function testCreateGeo2Index()
960956

961957
/**
962958
* Create a hash index and verify it by getting information about the index from the server
959+
* @deprecated the "hash" index type is deprecated on the server side
963960
*/
964961
public function testCreateHashIndex()
965962
{
@@ -994,6 +991,7 @@ public function testCreateHashIndex()
994991

995992
/**
996993
* Create a sparse hash index and verify it by getting information about the index from the server
994+
* @deprecated the "hash" index type is deprecated on the server side
997995
*/
998996
public function testCreateSparseHashIndex()
999997
{
@@ -1029,6 +1027,7 @@ public function testCreateSparseHashIndex()
10291027

10301028
/**
10311029
* Create a fulltext index and verify it by getting information about the index from the server
1030+
* @deprecated the "fulltext" index type is deprecated from ArangoDB 3.10 onwards
10321031
*/
10331032
public function testCreateFulltextIndex()
10341033
{
@@ -1059,6 +1058,7 @@ public function testCreateFulltextIndex()
10591058

10601059
/**
10611060
* Create a skiplist index and verify it by getting information about the index from the server
1061+
* @deprecated the "skiplist" index type is deprecated on the server side
10621062
*/
10631063
public function testCreateSkipListIndex()
10641064
{
@@ -1091,6 +1091,7 @@ public function testCreateSkipListIndex()
10911091

10921092
/**
10931093
* Create a sparse skiplist index and verify it by getting information about the index from the server
1094+
* @deprecated the "skiplist" index type is deprecated on the server side
10941095
*/
10951096
public function testCreateSparseSkipListIndex()
10961097
{
@@ -1221,6 +1222,7 @@ public function testCreateTtlIndex()
12211222

12221223
/**
12231224
* Test creating an index and getting it to verify.
1225+
* @deprecated the "fulltext" index type is deprecated from ArangoDB 3.10 onwards
12241226
*/
12251227
public function testGetIndex()
12261228
{
@@ -1251,12 +1253,14 @@ public function testGetIndex()
12511253
*/
12521254
public function testCreateIndexInBackground()
12531255
{
1254-
$result = $this->collectionHandler->createHashIndex(
1255-
'ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp,
1256-
['test'],
1257-
false,
1258-
false,
1259-
true
1256+
$result = $this->collectionHandler->createIndex(
1257+
'ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp, [
1258+
'type' => 'persistent',
1259+
'fields' => ['test'],
1260+
'unique' => false,
1261+
'sparse' => false,
1262+
'inBackground' => true
1263+
]
12601264
);
12611265

12621266
$indices = $this->collectionHandler->getIndexes('ArangoDB_PHP_TestSuite_IndexTestCollection' . '_' . static::$testsTimestamp);
@@ -1268,7 +1272,7 @@ public function testCreateIndexInBackground()
12681272
$indexInfo = $indicesByIdentifiers[$result['id']];
12691273

12701274
static::assertEquals(
1271-
CollectionHandler::OPTION_HASH_INDEX,
1275+
CollectionHandler::OPTION_PERSISTENT_INDEX,
12721276
$indexInfo[CollectionHandler::OPTION_TYPE]
12731277
);
12741278
static::assertEquals(['test'], $indexInfo['fields']);

tests/CollectionExtendedTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,7 @@ public function testGetAll()
20382038

20392039
/**
20402040
* test for creation of a hash index
2041+
* @deprecated the "hash" index type is deprecated on the server side
20412042
*/
20422043
public function testCreateHashIndex()
20432044
{
@@ -2070,7 +2071,7 @@ public function testCreateHashIndex()
20702071
/**
20712072
* test for creation of a hash index, uniqueness violation
20722073
*/
2073-
public function testCreateUniqueHashIndex()
2074+
public function testCreateUniquePersistentIndex()
20742075
{
20752076
// set up collections, indexes and test-documents
20762077
$collectionHandler = $this->collectionHandler;
@@ -2086,7 +2087,7 @@ public function testCreateUniqueHashIndex()
20862087
$documentHandler->save($collection->getName(), $document2);
20872088

20882089
try {
2089-
$collectionHandler->index($collection->getName(), 'hash', ['index'], true);
2090+
$collectionHandler->index($collection->getName(), 'persistent', ['index'], true);
20902091
} catch (ServerException $e) {
20912092
static::assertInstanceOf(
20922093
ServerException::class,
@@ -2105,6 +2106,7 @@ public function testCreateUniqueHashIndex()
21052106

21062107
/**
21072108
* test for creation of a skip-list indexed collection and querying by range (first level and nested), with closed, skip and limit options
2109+
* @deprecated the functionality is deprecated on the server side
21082110
*/
21092111

21102112
public function testCreateSkipListIndexedCollectionAddDocumentsAndQueryRange()
@@ -2456,6 +2458,7 @@ public function testCreateGeoIndexedCollectionAddDocumentsAndQueryWithin()
24562458

24572459
/**
24582460
* test for creation of a fulltext indexed collection and querying by within, with distance, skip and limit options
2461+
* @deprecated the "fulltext" index type is deprecated from ArangoDB 3.10 onwards
24592462
*/
24602463
public function testCreateFulltextIndexedCollectionAddDocumentsAndQuery()
24612464
{
@@ -2491,6 +2494,7 @@ public function testCreateFulltextIndexedCollectionAddDocumentsAndQuery()
24912494

24922495
/**
24932496
* Test if we can create a full text index with options, on a collection
2497+
* @deprecated the "fulltext" index type is deprecated from ArangoDB 3.10 onwards
24942498
*/
24952499
public function testCreateFulltextIndexedCollectionWithOptions()
24962500
{

0 commit comments

Comments
 (0)