aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/elasticsearch_tools.py
diff options
context:
space:
mode:
authorPjotr Prins2018-02-15 10:30:52 +0000
committerPjotr Prins2018-02-15 10:30:52 +0000
commit9d47ad572f46397bdd778d8f6e1c37d40e12aa2a (patch)
treefad90338598a0a6b6589f0106a411f1f37cd22e0 /wqflask/utility/elasticsearch_tools.py
parentd636315ad629cb56ea3e697924160432f6132792 (diff)
downloadgenenetwork2-9d47ad572f46397bdd778d8f6e1c37d40e12aa2a.tar.gz
Fixing authentication stuff so it uses parameters properly. Also no PYTHONPATH needed as
it is now in the Guix build.
Diffstat (limited to 'wqflask/utility/elasticsearch_tools.py')
-rw-r--r--wqflask/utility/elasticsearch_tools.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py
index a964b025..2d3d5add 100644
--- a/wqflask/utility/elasticsearch_tools.py
+++ b/wqflask/utility/elasticsearch_tools.py
@@ -1,10 +1,18 @@
from elasticsearch import Elasticsearch, TransportError
import logging
+from utility.logger import getLogger
+logger = getLogger(__name__)
+
+from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT
+
def get_elasticsearch_connection():
+ logger.info("get_elasticsearch_connection")
es = None
try:
- from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT
+ assert(ELASTICSEARCH_HOST)
+ assert(ELASTICSEARCH_PORT)
+ logger.info("ES HOST",ELASTICSEARCH_HOST)
es = Elasticsearch([{
"host": ELASTICSEARCH_HOST
@@ -31,12 +39,12 @@ def get_item_by_unique_column(es, column_name, column_value, index, doc_type):
response = es.search(
index = index
, doc_type = doc_type
- , body = {
- "query": { "match": { column_name: column_value } }
+ , body = {
+ "query": { "match": { column_name: column_value } }
})
if len(response["hits"]["hits"]) > 0:
item_details = response["hits"]["hits"][0]["_source"]
- except TransportError as te:
+ except TransportError as te:
pass
return item_details