Skip to content
Closed
Prev Previous commit
Next Next commit
Index improvements for 2.5
  • Loading branch information
Joohwan Oh committed Jun 12, 2015
commit 236384dc96e2cfce8f9020f8b678d12e99127459
12 changes: 10 additions & 2 deletions arango/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,18 +1009,22 @@ def _add_index(self, data):
if res.status_code not in {200, 201}:
raise IndexAddError(res)

def add_hash_index(self, fields, unique=None):
def add_hash_index(self, fields, unique=None, sparse=None):
"""Add a new hash index to this collection.

:param fields: the attribute paths to index
:type fields: list
:param unique: whether or not the index is unique
:type unique: bool or None
:param sparse: whether to index attr values of null
:type sparse: bool or None
:raises: IndexAddError
"""
data = {"type": "hash", "fields": fields}
if unique is not None:
data["unique"] = unique
if sparse is not None:
data["sparse"] = sparse
self._add_index(data)

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

def add_skiplist_index(self, fields, unique=None):
def add_skiplist_index(self, fields, unique=None, sparse=None):
"""Add a new skiplist index to this collection.

A skiplist index is used to find ranges of documents (e.g. time).
Expand All @@ -1048,11 +1052,15 @@ def add_skiplist_index(self, fields, unique=None):
:type fields: list
:param unique: whether or not the index is unique
:type unique: bool or None
:param sparse: whether to index attr values of null
:type sparse: bool or None
:raises: IndexAddError
"""
data = {"type": "skiplist", "fields": fields}
if unique is not None:
data["unique"] = unique
if sparse is not None:
data["sparse"] = sparse
self._add_index(data)

def add_geo_index(self, fields, geo_json=None, unique=None,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
setup(
name="py-arango",
description="Python Driver for ArangoDB",
version="1.2.0",
version="1.3.0",
author="Joohwan Oh",
author_email="joowani88@gmail.com",
url="https://github.com/Joowani/py-arango",
Expand Down