T53161 elasticsearch can index nodes now. cli command. NOTE config changes!!

This commit is contained in:
2017-11-10 16:05:12 +01:00
parent 43fa8f1a45
commit d2a8f2a47f
13 changed files with 303 additions and 19 deletions

View File

@@ -1,10 +1,25 @@
import logging
from pillar import current_app
from elasticsearch_dsl.connections import connections
from . import documents
elk_hosts = current_app.config['ELASTIC_SEARCH_HOSTS']
connections.create_connection(
hosts=elk_hosts,
sniff_on_start=True,
timeout=20)
log = logging.getLogger(__name__)
def push_updated_user(user_to_index: dict):
"""Push an update to the Algolia index when a user item is updated"""
"""
Push an update to the Elastic index when
a user item is updated.
"""
log.warning(
'WIP USER ELK INDEXING %s %s',
@@ -15,11 +30,18 @@ def push_updated_user(user_to_index: dict):
def index_node_save(node_to_index: dict):
log.warning(
'WIP USER NODE INDEXING %s',
'ELK NODE INDEXING %s',
node_to_index.get('objectID'))
log.warning(node_to_index)
doc = documents.create_doc_from_node_data(node_to_index)
log.warning('CREATED ELK DOC')
doc.save()
def index_node_delete(delete_id: str):
log.warning(
'WIP NODE DELETE INDEXING %s', delete_id)
log.warning('NODE DELETE INDEXING %s', delete_id)
documents.Node(id=delete_id).delete()