diff --git a/datagateway_api/src/search_api/panosc_mappings.py b/datagateway_api/src/search_api/panosc_mappings.py index 0e868d2e..c5f1ffe2 100644 --- a/datagateway_api/src/search_api/panosc_mappings.py +++ b/datagateway_api/src/search_api/panosc_mappings.py @@ -118,9 +118,11 @@ def get_panosc_non_related_field_names(self, panosc_entity_name): non_related_field_names = [] for mapping_key, mapping_value in entity_mappings.items(): - # The mappings for the non-related fields are of type `str` whereas for - # the related fields, they are of type `dict`. We only need the former. - if mapping_key != "base_icat_entity" and isinstance(mapping_value, str): + # The mappings for the non-related fields are of type `str` and sometimes + # `list' whereas for the related fields, they are of type `dict`. + if mapping_key != "base_icat_entity" and ( + isinstance(mapping_value, str) or isinstance(mapping_value, list) + ): non_related_field_names.append(mapping_key) return non_related_field_names @@ -141,13 +143,17 @@ def get_icat_relations_for_panosc_non_related_fields(self, panosc_entity_name): for field_name in field_names: _, icat_mapping = self.get_icat_mapping(panosc_entity_name, field_name) - split_icat_mapping = icat_mapping.split(".") - if len(split_icat_mapping) > 1: - # Remove the last split element because it is an ICAT - # field name and is not therefore part of the relation - split_icat_mapping = split_icat_mapping[:-1] - icat_mapping = ".".join(split_icat_mapping) - icat_relations.append(icat_mapping) + if not isinstance(icat_mapping, list): + icat_mapping = [icat_mapping] + + for mapping in icat_mapping: + split_mapping = mapping.split(".") + if len(split_mapping) > 1: + # Remove the last split element because it is an ICAT + # field name and is not therefore part of the relation + split_mapping = split_mapping[:-1] + split_mapping = ".".join(split_mapping) + icat_relations.append(split_mapping) return icat_relations