diff --git a/site/tests/conftest.py b/site/tests/conftest.py index 6cdc48b5..b5f21b1f 100644 --- a/site/tests/conftest.py +++ b/site/tests/conftest.py @@ -26,7 +26,6 @@ from invenio_vocabularies.contrib.funders.api import Funder from invenio_vocabularies.proxies import current_service as vocabulary_service from invenio_vocabularies.records.api import Vocabulary - from zenodo_rdm.api import ZenodoRDMDraft, ZenodoRDMRecord from zenodo_rdm.custom_fields import CUSTOM_FIELDS, CUSTOM_FIELDS_UI, NAMESPACES from zenodo_rdm.generators import media_files_management_action @@ -86,6 +85,22 @@ def app_config(app_config): return app_config +@pytest.fixture(scope="module") +def search(search): + from invenio_search import current_search, current_search_client + from invenio_search.engine import search + + try: + list(current_search.put_templates()) + list(current_search.put_index_templates()) + except search.RequestError: + pass + + current_search_client.indices.refresh() + yield search + # Cleanup? + + @pytest.fixture(scope="function") def db_session_options(): """Database session options.""" diff --git a/site/zenodo_rdm/index_templates/os-v2/rdmrecords-template.json b/site/zenodo_rdm/index_templates/os-v2/rdmrecords-template.json index 793d590a..b0374e3f 100644 --- a/site/zenodo_rdm/index_templates/os-v2/rdmrecords-template.json +++ b/site/zenodo_rdm/index_templates/os-v2/rdmrecords-template.json @@ -1,9 +1,23 @@ { "priority": 100, - "index_patterns": ["__SEARCH_INDEX_PREFIX__rdmrecords-*"], + "index_patterns": [ + "__SEARCH_INDEX_PREFIX__rdmrecords-*" + ], "template": { "settings": { - "number_of_shards": 3 + "number_of_shards": 3 + }, + "mappings": { + "properties": { + "swh": { + "type": "object", + "properties": { + "swhid": { + "type": "keyword" + } + } + } + } } } }