Skip to content

Commit

Permalink
Merge pull request #794 from aaxelb/feature/suid-guid
Browse files Browse the repository at this point in the history
[no ticket] index suid for search
  • Loading branch information
aaxelb committed Aug 9, 2022
2 parents d2c268f + b2d5b2a commit 938ed3e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions share/metadata_formats/sharev2_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def format(self, normalized_datum):
return json.dumps(strip_empty_values({
'id': IDObfuscator.encode(suid),
'sources': [source_name],
'source_config': suid.source_config.label,
'source_unique_id': suid.identifier,

'type': format_node_type(central_work),
'types': format_node_type_lineage(central_work),
Expand Down
2 changes: 2 additions & 0 deletions share/search/index_setup/postrend_backcompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def index_mappings(self):
'publishers': {'type': 'text', 'fields': exact_field},
'registration_type': {'type': 'keyword', 'include_in_all': False},
'retracted': {'type': 'boolean', 'include_in_all': False},
'source_config': {'type': 'keyword', 'include_in_all': False},
'source_unique_id': {'type': 'keyword'},
'sources': {'type': 'keyword', 'include_in_all': False},
'subjects': {'type': 'text', 'include_in_all': False, 'analyzer': 'subject_analyzer', 'search_analyzer': 'subject_search_analyzer'},
'subject_synonyms': {'type': 'text', 'include_in_all': False, 'analyzer': 'subject_analyzer', 'search_analyzer': 'subject_search_analyzer', 'copy_to': 'subjects'},
Expand Down
12 changes: 12 additions & 0 deletions tests/share/metadata_formats/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
FORMATTER_TEST_INPUTS = {
'mycorrhizas': {
'suid_id': 7,
'suid_value': 'oof',
'source_name': 'SomeSource',
'source_config_label': 'foo',
'raw_datum_kwargs': {
'date_created': dateutil.parser.isoparse('2017-04-07T21:09:05.023090+00:00'),
},
Expand All @@ -33,7 +35,9 @@
},
'no-names-only-name-parts': {
'suid_id': 7,
'suid_value': 'rab',
'source_name': 'SomeSource',
'source_config_label': 'bar',
'raw_datum_kwargs': {
'date_created': dateutil.parser.isoparse('2017-04-07T21:09:05.023090+00:00'),
},
Expand All @@ -54,7 +58,9 @@
},
'with-is_deleted': {
'suid_id': 57,
'suid_value': 'zab',
'source_name': 'foo',
'source_config_label': 'baz',
'raw_datum_kwargs': {},
'normalized_datum_kwargs': {
'data': {
Expand All @@ -67,7 +73,9 @@
},
'with-subjects': {
'suid_id': 123,
'suid_value': 'xuq',
'source_name': 'osf reg',
'source_config_label': 'subj',
'raw_datum_kwargs': {
'date_created': dateutil.parser.isoparse('2020-02-02T20:20:02.02+00:00'),
},
Expand Down Expand Up @@ -325,7 +333,9 @@
},
'with-osf-extra': {
'suid_id': 99,
'suid_value': 'guidz',
'source_name': 'OsfProbably',
'source_config_label': 'osf.io.v2_push',
'raw_datum_kwargs': {
'date_created': dateutil.parser.isoparse('2017-04-07T21:09:05.023090+00:00'),
},
Expand Down Expand Up @@ -416,6 +426,8 @@ def normalized_datum(self, formatter_test_input):
return NormalizedDataFactory(
raw=RawDatumFactory(
suid__id=formatter_test_input['suid_id'],
suid__identifier=formatter_test_input['suid_value'],
suid__source_config__label=formatter_test_input['source_config_label'],
suid__source_config__source__long_title=formatter_test_input['source_name'],
**formatter_test_input['raw_datum_kwargs'],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def assert_formatter_outputs_equal(self, actual_output, expected_output):
'identifiers': ['http://dx.doi.org/10.5772/9813'],
'publishers': ['InTech'],
'retracted': False,
'source_config': 'foo',
'source_unique_id': 'oof',
'sources': ['SomeSource'],
'title': 'The Role of Mycorrhizas in Forest Soil Stability with Climate Change',
'type': 'creative work',
Expand Down Expand Up @@ -102,6 +104,8 @@ def assert_formatter_outputs_equal(self, actual_output, expected_output):
'identifiers': ['http://dx.doi.org/10.5772/9813'],
'publishers': [],
'retracted': False,
'source_config': 'bar',
'source_unique_id': 'rab',
'sources': ['SomeSource'],
'title': 'The Role of Mycorrhizas in Forest Soil Stability with Climate Change',
'type': 'creative work',
Expand Down Expand Up @@ -157,6 +161,8 @@ def assert_formatter_outputs_equal(self, actual_output, expected_output):
'identifiers': ['http://staging.osf.io/chair/'],
'registration_type': 'Open-Ended Registration',
'retracted': False,
'source_config': 'subj',
'source_unique_id': 'xuq',
'sources': ['osf reg'],
'subject_synonyms': [
'bepress|Life Sciences|Biology',
Expand Down Expand Up @@ -223,6 +229,8 @@ def assert_formatter_outputs_equal(self, actual_output, expected_output):
'date_updated': '2017-03-31T05:39:48+00:00',
'id': 'encoded-99',
'identifiers': ['https://example.com/open'],
'source_config': 'osf.io.v2_push',
'source_unique_id': 'guidz',
'sources': ['OsfProbably'],
'subject_synonyms': [],
'subjects': [],
Expand Down

0 comments on commit 938ed3e

Please sign in to comment.