Skip to content

Commit 17f4e49

Browse files
authored
Implement 3.10 index API changes (#215)
1 parent 6da57e0 commit 17f4e49

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

arango/collection.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ def add_geo_index(
11371137
ordered: Optional[bool] = None,
11381138
name: Optional[str] = None,
11391139
in_background: Optional[bool] = None,
1140+
legacyPolygons: Optional[bool] = False,
11401141
) -> Result[Json]:
11411142
"""Create a new geo-spatial index.
11421143
@@ -1151,6 +1152,9 @@ def add_geo_index(
11511152
:type name: str | None
11521153
:param in_background: Do not hold the collection lock.
11531154
:type in_background: bool | None
1155+
:param legacyPolygons: Whether or not to use use the old, pre-3.10 rules
1156+
for the parsing GeoJSON polygons
1157+
:type legacyPolygons: bool | None
11541158
:return: New index details.
11551159
:rtype: dict
11561160
:raise arango.exceptions.IndexCreateError: If create fails.
@@ -1163,6 +1167,8 @@ def add_geo_index(
11631167
data["name"] = name
11641168
if in_background is not None:
11651169
data["inBackground"] = in_background
1170+
if legacyPolygons is not None:
1171+
data["legacyPolygons"] = legacyPolygons
11661172

11671173
return self._add_index(data)
11681174

@@ -1173,7 +1179,9 @@ def add_fulltext_index(
11731179
name: Optional[str] = None,
11741180
in_background: Optional[bool] = None,
11751181
) -> Result[Json]:
1176-
"""Create a new fulltext index.
1182+
"""Create a new fulltext index. This method is deprecated
1183+
in ArangoDB 3.10 and will be removed in a future version
1184+
of the driver.
11771185
11781186
:param fields: Document fields to index.
11791187
:type fields: [str]
@@ -1205,6 +1213,8 @@ def add_persistent_index(
12051213
sparse: Optional[bool] = None,
12061214
name: Optional[str] = None,
12071215
in_background: Optional[bool] = None,
1216+
storedValues: Sequence[str] = [],
1217+
cacheEnabled: Optional[bool] = None,
12081218
) -> Result[Json]:
12091219
"""Create a new persistent index.
12101220
@@ -1223,6 +1233,16 @@ def add_persistent_index(
12231233
:type name: str | None
12241234
:param in_background: Do not hold the collection lock.
12251235
:type in_background: bool | None
1236+
:param storedValues: Additional attributes to include in a persistent
1237+
index. These additional attributes cannot be used for index
1238+
lookups or sorts, but they can be used for projections. Must be
1239+
an array of index attribute paths. There must be no overlap of
1240+
attribute paths between fields and storedValues. The maximum
1241+
number of values is 32.
1242+
:type storedValues: [str]
1243+
:param cacheEnabled: Enable an in-memory cache for index values for
1244+
persistent indexes.
1245+
:type cacheEnabled: bool | None
12261246
:return: New index details.
12271247
:rtype: dict
12281248
:raise arango.exceptions.IndexCreateError: If create fails.
@@ -1237,6 +1257,10 @@ def add_persistent_index(
12371257
data["name"] = name
12381258
if in_background is not None:
12391259
data["inBackground"] = in_background
1260+
if storedValues is not None:
1261+
data["storedValues"] = storedValues
1262+
if cacheEnabled is not None:
1263+
data["cacheEnabled"] = cacheEnabled
12401264

12411265
return self._add_index(data)
12421266

arango/formatter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def format_index(body: Json) -> Json:
5959
result["worst_indexed_level"] = body["worstIndexedLevel"]
6060
if "maxNumCoverCells" in body:
6161
result["max_num_cover_cells"] = body["maxNumCoverCells"]
62+
if "storedValues" in body:
63+
result["storedValues"] = body["storedValues"]
64+
if "cacheEnabled" in body:
65+
result["cacheEnabled"] = body["cacheEnabled"]
66+
if "legacyPolygons" in body:
67+
result["legacyPolygons"] = body["legacyPolygons"]
6268

6369
return verify_format(body, result)
6470

0 commit comments

Comments
 (0)