diff --git a/invenio_records_resources/factories/factory.py b/invenio_records_resources/factories/factory.py index ae9932d5..5b897958 100644 --- a/invenio_records_resources/factories/factory.py +++ b/invenio_records_resources/factories/factory.py @@ -9,6 +9,7 @@ # details. """Record type factory.""" + from invenio_db import db from invenio_pidstore.providers.recordid_v2 import RecordIdProviderV2 from invenio_records.dumpers import SearchDumper @@ -51,6 +52,7 @@ def __init__( record_relations=None, schema_path=None, index_name=None, + search_alias=None, search_options=None, service_components=None, permission_policy_cls=None, @@ -81,6 +83,7 @@ def __init__( self.record_relations = record_relations self.schema_path = self._build_schema_path(schema_path) self.index_name = self._build_index_name(index_name) + self.search_alias = search_alias or self.name_plural self.model_cls_attrs = model_cls_attrs or {} self.record_cls_attrs = record_cls_attrs or {} self.resource_cls_attrs = resource_cls_attrs or {} @@ -152,7 +155,7 @@ def create_record_class(self): record_class_attributes = { "model_cls": self.model_cls, "schema": ConstantField("$schema", self.schema_path), - "index": IndexField(self.index_name), + "index": IndexField(self.index_name, search_alias=self.search_alias), "pid": pid_field, "dumper": self.record_dumper or SearchDumper(), }