diff --git a/README.md b/README.md index 2f82fbc4..6db1b7f6 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ db = client.db("test", username="root", password="passwd") # Create a new collection named "students". students = db.create_collection("students") -# Add a hash index to the collection. -students.add_hash_index(fields=["name"], unique=True) +# Add a persistent index to the collection. +students.add_persistent_index(fields=["name"], unique=True) # Insert new documents into the collection. students.insert({"name": "jane", "age": 39}) diff --git a/arango/collection.py b/arango/collection.py index 181ac001..820c5200 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -1293,6 +1293,13 @@ def add_hash_index( ) -> Result[Json]: """Create a new hash index. + .. warning:: + + The index types `hash` and `skiplist` are aliases for the persistent + index type and should no longer be used to create new indexes. The + aliases will be removed in a future version. Use + :func:`arango.collection.Collection.add_persistent_index` instead. + :param fields: Document fields to index. :type fields: [str] :param unique: Whether the index is unique. @@ -1337,6 +1344,13 @@ def add_skiplist_index( ) -> Result[Json]: """Create a new skiplist index. + .. warning:: + + The index types `hash` and `skiplist` are aliases for the persistent + index type and should no longer be used to create new indexes. The + aliases will be removed in a future version. Use + :func:`arango.collection.Collection.add_persistent_index` instead. + :param fields: Document fields to index. :type fields: [str] :param unique: Whether the index is unique. diff --git a/arango/formatter.py b/arango/formatter.py index 6a730b87..c948f279 100644 --- a/arango/formatter.py +++ b/arango/formatter.py @@ -104,6 +104,10 @@ def format_index(body: Json) -> Json: if "fieldValueTypes" in body: result["field_value_types"] = body["fieldValueTypes"] + # Introduced in 3.12 EE + if "optimizeTopK" in body: + result["optimizeTopK"] = body["optimizeTopK"] + return verify_format(body, result) diff --git a/docs/indexes.rst b/docs/indexes.rst index 01750146..d752f732 100644 --- a/docs/indexes.rst +++ b/docs/indexes.rst @@ -27,15 +27,15 @@ on fields ``_from`` and ``_to``. For more information on indexes, refer to # List the indexes in the collection. cities.indexes() - # Add a new hash index on document fields "continent" and "country". - index = cities.add_hash_index(fields=['continent', 'country'], unique=True) + # Add a new persistent index on document fields "continent" and "country". + index = cities.add_persistent_index(fields=['continent', 'country'], unique=True) # Add new fulltext indexes on fields "continent" and "country". index = cities.add_fulltext_index(fields=['continent']) index = cities.add_fulltext_index(fields=['country']) - # Add a new skiplist index on field 'population'. - index = cities.add_skiplist_index(fields=['population'], sparse=False) + # Add a new persistent index on field 'population'. + index = cities.add_persistent_index(fields=['population'], sparse=False) # Add a new geo-spatial index on field 'coordinates'. index = cities.add_geo_index(fields=['coordinates']) @@ -47,7 +47,7 @@ on fields ``_from`` and ``_to``. For more information on indexes, refer to index = cities.add_ttl_index(fields=['currency'], expiry_time=200) # Indexes may be added with a name that can be referred to in AQL queries. - index = cities.add_hash_index(fields=['country'], name='my_hash_index') + index = cities.add_persistent_index(fields=['country'], name='my_persistent_index') # Delete the last index from the collection. cities.delete_index(index['id']) diff --git a/tests/static/single-3.12.conf b/tests/static/single-3.12.conf index 424d809e..d5df3aa9 100644 --- a/tests/static/single-3.12.conf +++ b/tests/static/single-3.12.conf @@ -10,4 +10,4 @@ jwt-secret = /tests/static/keyfile all.database.password = passwd all.database.extended-names = true all.javascript.allow-admin-execute = true -all.server.options-api = admin \ No newline at end of file +all.server.options-api = admin