Skip to content

Commit 213964e

Browse files
committed
update get
1 parent 8b099b4 commit 213964e

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

pyepsilla/vectordb/client.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ def get(
303303
filter: Optional[str] = None,
304304
skip: Optional[int] = None,
305305
limit: Optional[int] = None,
306+
facets: Optional[list[dict]] = None,
306307
):
307308
if self._db is None:
308309
raise Exception("[ERROR] Please use_db() first!")
@@ -319,21 +320,31 @@ def get(
319320

320321
req_data = {"table": table_name}
321322

322-
if response_fields != None:
323+
if response_fields is not None:
323324
req_data["response"] = response_fields
324325

325-
if primary_keys != None:
326+
if primary_keys is not None:
326327
req_data["primaryKeys"] = primary_keys
327328

328-
if filter != None:
329+
if filter is not None:
329330
req_data["filter"] = filter
330331

331-
if skip != None:
332+
if skip is not None:
332333
req_data["skip"] = filter
333334

334-
if limit != None:
335+
if limit is not None:
335336
req_data["limit"] = limit
336337

338+
if facets is not None and len(facets) > 0:
339+
aggregate_not_existing = 0
340+
for facet in facets:
341+
if "aggregate" not in facet:
342+
aggregate_not_existing += 1
343+
if aggregate_not_existing > 0:
344+
raise Exception("[ERROR] key aggregate is a must in facets!")
345+
else:
346+
req_data["facets"] = facets
347+
337348
req_url = "{}/api/{}/data/get".format(self._baseurl, self._db)
338349
res = requests.post(
339350
url=req_url, data=json.dumps(req_data), headers=self._header, verify=False

0 commit comments

Comments
 (0)