From dfc01270ff62e21168e8003b9d3d9f4c7bc26efb Mon Sep 17 00:00:00 2001 From: George Date: Thu, 31 Jul 2025 11:01:03 -0700 Subject: [PATCH 1/2] fix for issue #1475. Not very elegant! --- idc_collections/collex_metadata_utils.py | 5 +++++ solr_helpers/__init__.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/idc_collections/collex_metadata_utils.py b/idc_collections/collex_metadata_utils.py index f8eacf05..e7f6204b 100644 --- a/idc_collections/collex_metadata_utils.py +++ b/idc_collections/collex_metadata_utils.py @@ -1100,6 +1100,11 @@ def create_query_set(solr_query, sources, source, all_ui_attrs, image_source, Da query_set.append(solr_query['queries'][attr]) else: attStr = solr_query['queries'][attr].replace('"', '\\"') + # certain attributes values include quotes, ie Manufacturer = \"GE Healthcare\" which leads to 'subqueries' + # in filter strings with nested quotes, ie, + # _query_:"{!join to=StudyInstanceUID from=StudyInstanceUID}(+Manufacturer:(""GE Healthcare""))")) + # in this case extra backslashes are needed around the inner quotes + attStr = attStr.replace('\\\\"', '\\\\\\"') attStr = '(_query_:"{!join to=' + default_join_field + ' from=' + default_join_field + '}' + attStr + '")' query_set.append(attStr) # If it's in another source for this program, we need to join on that source diff --git a/solr_helpers/__init__.py b/solr_helpers/__init__.py index c14df26f..acb65188 100644 --- a/solr_helpers/__init__.py +++ b/solr_helpers/__init__.py @@ -572,6 +572,11 @@ def build_solr_query(filters, comb_with='AND', with_tags_for_ex=False, subq_join "{!join to=%s from=%s}%s" % (search_child_records_by[attr_name], search_child_records_by[attr_name], query_str.replace("\"", "\\\""))) + # certain attributes values include quotes, ie Manufacturer = \"GE Healthcare\" which leads to 'subqueries' + # in filter strings with nested quotes, ie, + # _query_:"{!join to=StudyInstanceUID from=StudyInstanceUID}(+Manufacturer:(""GE Healthcare""))")) + # in this case extra backslashes are needed around the inner quotes + query_str = query_str.replace('\\\\"','\\\\\\"') full_query_str += query_str if with_tags_for_ex: From 4fe3a6107b7ae5b42d5c859863fd8724d9ea14b2 Mon Sep 17 00:00:00 2001 From: George Date: Tue, 5 Aug 2025 14:07:36 -0700 Subject: [PATCH 2/2] fixes bug in which cart manifests were failing when 'None' type is selected --- idc_collections/collex_metadata_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idc_collections/collex_metadata_utils.py b/idc_collections/collex_metadata_utils.py index e7f6204b..6a235125 100644 --- a/idc_collections/collex_metadata_utils.py +++ b/idc_collections/collex_metadata_utils.py @@ -2295,7 +2295,7 @@ def get_cart_data_serieslvl(filtergrp_list, partitions, field_list, limit, offse solr_query = build_solr_query( copy.deepcopy(filtergrp), with_tags_for_ex=False, - search_child_records_by=None + search_child_records_by=None, solr_default_op='AND' ) query_set_for_filt = create_query_set(solr_query, aux_sources, image_source, all_ui_attrs, image_source, DataSetType, default_join_field='StudyInstanceUID')