Skip to content

Commit 236384d

Browse files
author
Joohwan Oh
committed
Index improvements for 2.5
1 parent 2f86b0f commit 236384d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

arango/collection.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,18 +1009,22 @@ def _add_index(self, data):
10091009
if res.status_code not in {200, 201}:
10101010
raise IndexAddError(res)
10111011

1012-
def add_hash_index(self, fields, unique=None):
1012+
def add_hash_index(self, fields, unique=None, sparse=None):
10131013
"""Add a new hash index to this collection.
10141014
10151015
:param fields: the attribute paths to index
10161016
:type fields: list
10171017
:param unique: whether or not the index is unique
10181018
:type unique: bool or None
1019+
:param sparse: whether to index attr values of null
1020+
:type sparse: bool or None
10191021
:raises: IndexAddError
10201022
"""
10211023
data = {"type": "hash", "fields": fields}
10221024
if unique is not None:
10231025
data["unique"] = unique
1026+
if sparse is not None:
1027+
data["sparse"] = sparse
10241028
self._add_index(data)
10251029

10261030
def add_cap_constraint(self, size=None, byte_size=None):
@@ -1039,7 +1043,7 @@ def add_cap_constraint(self, size=None, byte_size=None):
10391043
data["byteSize"] = byte_size
10401044
self._add_index(data)
10411045

1042-
def add_skiplist_index(self, fields, unique=None):
1046+
def add_skiplist_index(self, fields, unique=None, sparse=None):
10431047
"""Add a new skiplist index to this collection.
10441048
10451049
A skiplist index is used to find ranges of documents (e.g. time).
@@ -1048,11 +1052,15 @@ def add_skiplist_index(self, fields, unique=None):
10481052
:type fields: list
10491053
:param unique: whether or not the index is unique
10501054
:type unique: bool or None
1055+
:param sparse: whether to index attr values of null
1056+
:type sparse: bool or None
10511057
:raises: IndexAddError
10521058
"""
10531059
data = {"type": "skiplist", "fields": fields}
10541060
if unique is not None:
10551061
data["unique"] = unique
1062+
if sparse is not None:
1063+
data["sparse"] = sparse
10561064
self._add_index(data)
10571065

10581066
def add_geo_index(self, fields, geo_json=None, unique=None,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
setup(
88
name="py-arango",
99
description="Python Driver for ArangoDB",
10-
version="1.2.0",
10+
version="1.3.0",
1111
author="Joohwan Oh",
1212
author_email="joowani88@gmail.com",
1313
url="https://github.com/Joowani/py-arango",

0 commit comments

Comments
 (0)