diff options
author | Muriithi Frederick Muriuki | 2018-04-05 09:35:41 +0300 |
---|---|---|
committer | Muriithi Frederick Muriuki | 2018-04-05 09:35:41 +0300 |
commit | 90c367b206a846a08ce4bb06eeed7be31fe1c367 (patch) | |
tree | fe47ef5f4158494d49fdbca5a85c3985b37bed7c /wqflask/utility | |
parent | 31747256e466456cc88aac60780836a6534f18cd (diff) | |
parent | b152aca03be73655d2fb5eda17d533504ed900e2 (diff) | |
download | genenetwork2-90c367b206a846a08ce4bb06eeed7be31fe1c367.tar.gz |
Merge branch 'testing' of https://github.com/genenetwork/genenetwork2 into testing
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/elasticsearch_tools.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py index 075a8f65..d35cb5ee 100644 --- a/wqflask/utility/elasticsearch_tools.py +++ b/wqflask/utility/elasticsearch_tools.py @@ -12,6 +12,7 @@ def test_elasticsearch_connection(): logger.warning("Elasticsearch is DOWN") def get_elasticsearch_connection(): + """Return a connection to ES. Returns None on failure""" logger.info("get_elasticsearch_connection") es = None try: @@ -20,14 +21,14 @@ def get_elasticsearch_connection(): logger.info("ES HOST",ELASTICSEARCH_HOST) es = Elasticsearch([{ - "host": ELASTICSEARCH_HOST - , "port": ELASTICSEARCH_PORT + "host": ELASTICSEARCH_HOST, "port": ELASTICSEARCH_PORT }]) if (ELASTICSEARCH_HOST and ELASTICSEARCH_PORT) else None es_logger = logging.getLogger("elasticsearch") es_logger.setLevel(logging.INFO) es_logger.addHandler(logging.NullHandler()) except: + logger.error("Failed to get elasticsearch connection") es = None return es @@ -42,9 +43,7 @@ def get_item_by_unique_column(es, column_name, column_value, index, doc_type): item_details = None try: response = es.search( - index = index - , doc_type = doc_type - , body = { + index = index, doc_type = doc_type, body = { "query": { "match": { column_name: column_value } } }) if len(response["hits"]["hits"]) > 0: |