Skip to content

Commit 602a958

Browse files
committed
add facets
1 parent 78f5313 commit 602a958

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

pyepsilla/vectordb/client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import socket
88
import time
99
from typing import Optional, Union
10-
from ..utils.search_engine import SearchEngine
1110

1211
import requests
1312
import sentry_sdk
1413
from requests.packages.urllib3.exceptions import InsecureRequestWarning
1514

15+
from ..utils.search_engine import SearchEngine
16+
1617
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
1718

1819

@@ -253,6 +254,7 @@ def query(
253254
limit: int = 2,
254255
filter: str = "",
255256
with_distance: bool = False,
257+
facets: list[dict] = None,
256258
):
257259
if self._db is None:
258260
raise Exception("[ERROR] Please use_db() first!")
@@ -266,6 +268,15 @@ def query(
266268
"filter": filter,
267269
"withDistance": with_distance,
268270
}
271+
if facets is not None and len(facets) > 0:
272+
aggregate_not_existing = 0
273+
for facet in facets:
274+
if "aggregate" not in facet:
275+
aggregate_not_existing += 1
276+
if aggregate_not_existing > 0:
277+
raise Exception("[ERROR] key aggregate is a must in facets!")
278+
else:
279+
req_data["facets"] = facets
269280
if query_text is not None:
270281
req_data["query"] = query_text
271282
if query_index is not None:

0 commit comments

Comments
 (0)