aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorPjotr Prins2018-04-04 16:58:21 +0000
committerPjotr Prins2018-04-04 16:58:21 +0000
commit8145507d6d617554cf996e6cebf286d30ae64df0 (patch)
treefd820ef8bf1ca24dd312555c4d1e2eac6f9f112e /wqflask/utility
parent04280c8e1197384e426fe5b19230168f39e5ae94 (diff)
downloadgenenetwork2-8145507d6d617554cf996e6cebf286d30ae64df0.tar.gz
ES: doc
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/elasticsearch_tools.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py
index 734379f7..1dba357d 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: