From 4eb2fc1dc2e6c358f79bf58f080afa6511b2c8f0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 6 Aug 2020 23:08:43 -0700 Subject: re-use ES sync API client --- fatcat_scholar/search.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py index 891abff..c362ea6 100644 --- a/fatcat_scholar/search.py +++ b/fatcat_scholar/search.py @@ -87,13 +87,14 @@ class FulltextHits(BaseModel): results: List[Any] +# global sync client connection +es_client = elasticsearch.Elasticsearch(settings.ELASTICSEARCH_BACKEND, timeout=25.0) + + def do_fulltext_search( query: FulltextQuery, deep_page_limit: int = 2000 ) -> FulltextHits: - es_client = elasticsearch.Elasticsearch( - settings.ELASTICSEARCH_BACKEND, timeout=25.0 - ) search = Search(using=es_client, index=settings.ELASTICSEARCH_FULLTEXT_INDEX) # Convert raw DOIs to DOI queries -- cgit v1.2.3