aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-04-16 17:25:14 +0300
committerMuriithi Frederick Muriuki2018-04-16 17:25:14 +0300
commitbc1672f8617c56684ae3aeda7018362e818c46d6 (patch)
tree4215e0f9b82511edeb3dacde01a3f28de07e7a9f
parentfdd28defcaf3326f3c6b6507124708d83a1da119 (diff)
downloadgenenetwork2-bc1672f8617c56684ae3aeda7018362e818c46d6.tar.gz
Update mappings for Elasticsearch 6.2. Update logger
* Update the indexes mappings to be compatible with the newer Elasticsearch 6.2.* series. Close the index before updating it, and reopen it after to help with the re-indexing of the data. * Update the error logger to include the exception that was thrown.
-rw-r--r--wqflask/utility/elasticsearch_tools.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py
index 7d2ee8c9..0dc59d43 100644
--- a/wqflask/utility/elasticsearch_tools.py
+++ b/wqflask/utility/elasticsearch_tools.py
@@ -29,8 +29,8 @@ def get_elasticsearch_connection():
es_logger = logging.getLogger("elasticsearch")
es_logger.setLevel(logging.INFO)
es_logger.addHandler(logging.NullHandler())
- except:
- logger.error("Failed to get elasticsearch connection")
+ except Exception as e:
+ logger.error("Failed to get elasticsearch connection", e)
es = None
return es
@@ -40,11 +40,12 @@ def setup_users_index(es_connection):
index_settings = {
"properties": {
"email_address": {
- "type": "string"
- , "index": "not_analyzed"}}}
+ "type": "keyword"}}}
es_connection.indices.create(index='users', ignore=400)
+ es_connection.indices.close(index="users")
es_connection.indices.put_mapping(body=index_settings, index="users", doc_type="local")
+ es_connection.indices.open(index="users")
def get_user_by_unique_column(es, column_name, column_value, index="users", doc_type="local"):
return get_item_by_unique_column(es, column_name, column_value, index=index, doc_type=doc_type)