T53161 elasticsearch can index nodes now. cli command. NOTE config changes!!
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user