don't try to send messages of the wrong type
SearchIndexer.handle_messages_sync should filter out indexes that don't
support the given message type
+import logging
from contextlib import ExitStack
from django.apps import apps
@@ -11,6 +12,9 @@ from share.search.messages import MessageType
__all__ = ('SearchIndexer', 'MessageType')
+logger = logging.getLogger(__name__)
+
+
class SearchIndexer:
retry_policy = {
@@ -72,6 +76,10 @@ class SearchIndexer:
for index_name in index_names:
index_setup = self.elastic_manager.get_index_setup(index_name)
+ if message_type not in index_setup.supported_message_types:
+ logger.error(f'skipping: {index_name} does not support {message_type}')
+ continue
+
action_generator = index_setup.build_action_generator(index_name, message_type)
elastic_actions = [
elastic_action
