@@ -70,19 +70,22 @@ def test_connection(self):
7070 try :
7171 ts .collections .retrieve ()
7272 except typesense .exceptions .ObjectNotFound as exc :
73- raise UserError (_ ("Not Found - The requested resource is not found." )) from exc
73+ raise UserError (
74+ _ ("Not Found - The requested resource is not found." )
75+ ) from exc
7476 except typesense .RequestUnauthorized as exc :
7577 raise UserError (_ ("Unauthorized - Your API key is wrong." )) from exc
7678 except typesense .TypesenseClientError as exc :
7779 raise UserError (_ ("Unable to connect :" ) + "\n \n " + repr (exc )) from exc
7880
7981 def index (self , records ) -> None :
80- """
81- """
82+ """ """
8283 ts = self ._ts_client
8384 records_for_bulk = "\n " .join (records )
8485 pprint (records_for_bulk )
85- res = ts .collections [self ._index_name ].documents .import_ (records_for_bulk , {'action' : 'create' })
86+ res = ts .collections [self ._index_name ].documents .import_ (
87+ records_for_bulk , {"action" : "create" }
88+ )
8689 print (res )
8790 res = res .split ("\n " )
8891 # res = elasticsearch.helpers.bulk(es, records_for_bulk)
@@ -99,11 +102,12 @@ def index(self, records) -> None:
99102 )
100103
101104 def delete (self , binding_ids ) -> None :
102- """
103- """
105+ """ """
104106 ts = self ._ts_client
105107 print (f"delete ids: { binding_ids } " )
106- res = ts .collections [self ._index_name ].documents .delete ({"filter_by=id" : binding_ids })
108+ res = ts .collections [self ._index_name ].documents .delete (
109+ {"filter_by=id" : binding_ids }
110+ )
107111 print (f"deleted: { res } " )
108112
109113 # records_for_bulk = []
@@ -125,8 +129,7 @@ def delete(self, binding_ids) -> None:
125129 # _logger.info(msg, e)
126130
127131 def clear (self ) -> None :
128- """
129- """
132+ """ """
130133 ts = self ._ts_client
131134 index_name = self ._get_current_aliased_index_name () or self ._index_name
132135 res = ts .collections [index_name ].delete ()
@@ -143,13 +146,14 @@ def clear(self) -> None:
143146 # )
144147
145148 def each (self ) -> Iterator [dict [str , Any ]]:
146- """
147- """
149+ """ """
148150 ts = self ._ts_client
149151 # res = es.search(index=self._index_name, filter_path=["hits.hits._source"])
150- res = ts .collections [self ._index_name ].documents .search ({
151- "q" : "*" ,
152- })
152+ res = ts .collections [self ._index_name ].documents .search (
153+ {
154+ "q" : "*" ,
155+ }
156+ )
153157 pprint (res )
154158 if not res :
155159 # eg: empty index
@@ -168,12 +172,16 @@ def settings(self) -> None:
168172 aliased_index_name = self ._get_next_aliased_index_name ()
169173 # index_name / collection_name is part of the schema defined in self._index_config
170174 index_config = self ._index_config
171- index_config .update ({
172- "name" : aliased_index_name ,
173- })
175+ index_config .update (
176+ {
177+ "name" : aliased_index_name ,
178+ }
179+ )
174180 client .collections .create (index_config )
175181 # client.indices.create(index=aliased_index_name, body=self._index_config)
176- client .aliases .upsert (self ._index_name , {"collection_name" : aliased_index_name })
182+ client .aliases .upsert (
183+ self ._index_name , {"collection_name" : aliased_index_name }
184+ )
177185 # client.indices.put_alias(index=aliased_index_name, name=self._index_name)
178186 msg = "Missing index %s created."
179187 _logger .info (msg , self ._index_name )
0 commit comments