diff --git a/omero_search_engine/api/v1/resources/utils.py b/omero_search_engine/api/v1/resources/utils.py index dd83193..83d66a6 100644 --- a/omero_search_engine/api/v1/resources/utils.py +++ b/omero_search_engine/api/v1/resources/utils.py @@ -1263,16 +1263,17 @@ def get_studies_titles(idr_name, resource, data_source=None): resourse_res = search_index_using_search_after( res_index, resource_query, None, None, None ) - for item_ in resourse_res["results"]: - study_title["id"] = item_.get("id") - study_title["name"] = item_.get("name") - study_title["type"] = resource - # study_title["description"] = item_.get("description") - for value in item_.get("key_values"): - if value.get("name"): - value["key"] = value["name"] - del value["name"] - study_title["key_values"] = item_.get("key_values") + if len(resourse_res)>0: + for item_ in resourse_res["results"]: + study_title["id"] = item_.get("id") + study_title["name"] = item_.get("name") + study_title["type"] = resource + # study_title["description"] = item_.get("description") + for value in item_.get("key_values"): + if value.get("name"): + value["key"] = value["name"] + del value["name"] + study_title["key_values"] = item_.get("key_values") return study_title diff --git a/omero_search_engine/cache_functions/elasticsearch/transform_data.py b/omero_search_engine/cache_functions/elasticsearch/transform_data.py index 2428e73..12ebe20 100644 --- a/omero_search_engine/cache_functions/elasticsearch/transform_data.py +++ b/omero_search_engine/cache_functions/elasticsearch/transform_data.py @@ -287,11 +287,12 @@ def prepare_data(data, data_source, doc_type): row_to_insert["key_values"] = [] data_to_be_inserted[row["id"]] = row_to_insert key_value = row_to_insert["key_values"] - key_value.append( - { - "name": row.get("mapvalue_name"), - "value": row.get("mapvalue_value"), - "index": row.get("mapvalue_index"), + if row.get("mapvalue_name"): + key_value.append( + { + "name": row.get("mapvalue_name"), + "value": row.get("mapvalue_value"), + "index": row.get("mapvalue_index"), } )