File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77import socket
88import time
99from typing import Optional , Union
10- from ..utils .search_engine import SearchEngine
1110
1211import requests
1312import sentry_sdk
1413from requests .packages .urllib3 .exceptions import InsecureRequestWarning
1514
15+ from ..utils .search_engine import SearchEngine
16+
1617requests .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 :
You can’t perform that action at this time.
0 commit comments