Browse Source

HOT-FIX: Adiciona try/catch no Solr

pull/3304/head
Vinícius Cantuária 4 years ago
committed by eribeiro
parent
commit
0355abde55
  1. 12
      docker/solr_api.py

12
docker/solr_api.py

@ -27,9 +27,15 @@ class SolrClient:
def get_num_docs(self, collection_name): def get_num_docs(self, collection_name):
final_url = self.QUERY_DATA.format(self.url, collection_name) final_url = self.QUERY_DATA.format(self.url, collection_name)
res = requests.get(final_url) res = requests.get(final_url)
dic = res.json() if res.ok:
num_docs = dic["response"]["numFound"] try:
return num_docs dic = res.json()
return dic["response"]["numFound"]
except Exception as e:
print(F"Erro no get_num_docs: {e}")
print(res.content)
return 0
def list_collections(self): def list_collections(self):
req_url = self.LIST_COLLECTIONS.format(self.url) req_url = self.LIST_COLLECTIONS.format(self.url)

Loading…
Cancel
Save