2017-10-25 17:09:10 +02:00
|
|
|
import logging
|
2017-11-03 16:40:02 +01:00
|
|
|
from pillar import current_app
|
2017-10-25 17:09:10 +02:00
|
|
|
|
2017-11-03 16:40:02 +01:00
|
|
|
from . import algolia_indexing
|
|
|
|
# from . import elastic_indexing
|
2017-10-25 17:09:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2017-11-03 16:40:02 +01:00
|
|
|
# TODO(stephan) make index backend conditional on settings.
|
2017-10-25 17:09:10 +02:00
|
|
|
|
2017-11-03 16:40:02 +01:00
|
|
|
SEARCH_BACKENDS = {
|
|
|
|
'algolia': algolia_indexing,
|
|
|
|
'elastic': None, # elastic_indexing
|
|
|
|
}
|
2017-10-25 17:09:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
@current_app.celery.task(ignore_result=True)
|
|
|
|
def updated_user(user_id: str):
|
|
|
|
"""Push an update to the index when a user item is updated"""
|
|
|
|
|
2017-11-03 16:40:02 +01:00
|
|
|
algolia_indexing.push_updated_user(user_id)
|
2017-10-25 17:09:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
@current_app.celery.task(ignore_result=True)
|
|
|
|
def node_save(node_id: str):
|
|
|
|
|
2017-11-03 16:40:02 +01:00
|
|
|
algolia_indexing.index_node_save(node_id)
|
2017-10-25 17:09:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
@current_app.celery.task(ignore_result=True)
|
|
|
|
def node_delete(node_id: str):
|
|
|
|
|
2017-11-03 16:40:02 +01:00
|
|
|
algolia_indexing.index_node_delete(node_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_doc_to_index_from(node: dict):
|
|
|
|
"""
|
|
|
|
Given node build an to_index document
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|