From 8d4d89510165c6869a175268d6be6bd866b86f1a Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Mon, 4 Nov 2024 14:57:27 +0000 Subject: [PATCH] Fix issue of getting containers names with data source --- .../api/v1/resources/resource_analyser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/omero_search_engine/api/v1/resources/resource_analyser.py b/omero_search_engine/api/v1/resources/resource_analyser.py index 21009a6..ccfb0f8 100644 --- a/omero_search_engine/api/v1/resources/resource_analyser.py +++ b/omero_search_engine/api/v1/resources/resource_analyser.py @@ -851,6 +851,8 @@ def get_the_results( hits = results_["hits"]["hits"] if len(hits) > 0: for hit in hits: + if "resourcename" not in hit["_source"]: + continue if len(hits) > 0: if name and not description: returned_results[hit["_source"]["data_source"]] = [ @@ -871,18 +873,16 @@ def get_the_results( and name.lower() in item.get("description").lower() ) ] - elif "resourcename" in hit["_source"]: + else: returned_results[hit["_source"]["data_source"]] = [ item for item in hit["_source"]["resourcename"] ] - else: - return returned_results - # remove container description from the results, # should be added again later after cleaning up the description for k, item in returned_results.items(): - del item[0]["description"] + if len(item) > 0: + del item[0]["description"] return returned_results