aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-04-15 11:57:09 +0300
committerMuriithi Frederick Muriuki2018-04-15 11:57:09 +0300
commitfdd28defcaf3326f3c6b6507124708d83a1da119 (patch)
tree59c1479aee861831f46cf46dc3ac56d0ce1e2c85 /wqflask/utility
parent9ac9f94f3b1409ae3a47c8a9e890f578a69b020f (diff)
downloadgenenetwork2-fdd28defcaf3326f3c6b6507124708d83a1da119.tar.gz
Deactivate analysis of email_address field
* Prevent elasticsearch from analysing and tokenising the email_address field so as to avoid issue with getting back all email addresses with the same domain as the one being searched for.
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/elasticsearch_tools.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py
index d35cb5ee..7d2ee8c9 100644
--- a/wqflask/utility/elasticsearch_tools.py
+++ b/wqflask/utility/elasticsearch_tools.py
@@ -24,6 +24,8 @@ def get_elasticsearch_connection():
"host": ELASTICSEARCH_HOST, "port": ELASTICSEARCH_PORT
}]) if (ELASTICSEARCH_HOST and ELASTICSEARCH_PORT) else None
+ setup_users_index(es)
+
es_logger = logging.getLogger("elasticsearch")
es_logger.setLevel(logging.INFO)
es_logger.addHandler(logging.NullHandler())
@@ -33,6 +35,17 @@ def get_elasticsearch_connection():
return es
+def setup_users_index(es_connection):
+ if es_connection:
+ index_settings = {
+ "properties": {
+ "email_address": {
+ "type": "string"
+ , "index": "not_analyzed"}}}
+
+ es_connection.indices.create(index='users', ignore=400)
+ es_connection.indices.put_mapping(body=index_settings, index="users", doc_type="local")
+
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)