Skip to content

Commit e25f68a

Browse files
committed
fix(mappings): add swh field via index template
To make sure we always create the `swh` property in the records mappings, we can use an index template.
1 parent f9f7d67 commit e25f68a

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

site/tests/conftest.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from invenio_vocabularies.contrib.funders.api import Funder
2727
from invenio_vocabularies.proxies import current_service as vocabulary_service
2828
from invenio_vocabularies.records.api import Vocabulary
29-
3029
from zenodo_rdm.api import ZenodoRDMDraft, ZenodoRDMRecord
3130
from zenodo_rdm.custom_fields import CUSTOM_FIELDS, CUSTOM_FIELDS_UI, NAMESPACES
3231
from zenodo_rdm.generators import media_files_management_action
@@ -86,6 +85,22 @@ def app_config(app_config):
8685
return app_config
8786

8887

88+
@pytest.fixture(scope="module")
89+
def search(search):
90+
from invenio_search import current_search, current_search_client
91+
from invenio_search.engine import search
92+
93+
try:
94+
list(current_search.put_templates())
95+
list(current_search.put_index_templates())
96+
except search.RequestError:
97+
pass
98+
99+
current_search_client.indices.refresh()
100+
yield search
101+
# Cleanup?
102+
103+
89104
@pytest.fixture(scope="function")
90105
def db_session_options():
91106
"""Database session options."""
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
{
22
"priority": 100,
3-
"index_patterns": ["__SEARCH_INDEX_PREFIX__rdmrecords-*"],
3+
"index_patterns": [
4+
"__SEARCH_INDEX_PREFIX__rdmrecords-*"
5+
],
46
"template": {
57
"settings": {
6-
"number_of_shards": 3
8+
"number_of_shards": 3
9+
},
10+
"mappings": {
11+
"properties": {
12+
"swh": {
13+
"type": "object",
14+
"properties": {
15+
"swhid": {
16+
"type": "keyword"
17+
}
18+
}
19+
}
20+
}
721
}
822
}
923
}

0 commit comments

Comments
 (0)