Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

factories: add "search_alias" for index field #601

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion invenio_records_resources/factories/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {}
Expand Down Expand Up @@ -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(),
}
Expand Down