From 627bb45f03af372ce1b809e05930a799237fd2c9 Mon Sep 17 00:00:00 2001 From: Andrea Cecchi Date: Mon, 12 Feb 2024 17:33:27 +0100 Subject: [PATCH] some fixes --- config/dev/conf/schema.xml | 1 + src/rer/solrpush/browser/querybuilder.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/config/dev/conf/schema.xml b/config/dev/conf/schema.xml index ea9096c..24cb007 100644 --- a/config/dev/conf/schema.xml +++ b/config/dev/conf/schema.xml @@ -184,6 +184,7 @@ + diff --git a/src/rer/solrpush/browser/querybuilder.py b/src/rer/solrpush/browser/querybuilder.py index 06a1188..e459a97 100644 --- a/src/rer/solrpush/browser/querybuilder.py +++ b/src/rer/solrpush/browser/querybuilder.py @@ -23,6 +23,7 @@ class QueryBuilder(BaseView): + def _makequery( self, query=None, @@ -43,6 +44,7 @@ def _makequery( parsedquery = queryparser.parseFormquery( self.context, query, sort_on, sort_order ) + index_modifiers = getUtilitiesFor(IParsedQueryIndexModifier) for name, modifier in index_modifiers: if name in parsedquery: @@ -81,9 +83,15 @@ def _makequery( if isinstance(custom_query, dict) and custom_query: # Update the parsed query with an extra query dictionary. This may - # override the parsed query. The custom_query is a dictonary of + # override the parsed query. The custom_query is a dictionary of # index names and their associated query values. - parsedquery.update(custom_query) + for key in custom_query: + if isinstance(parsedquery.get(key), dict) and isinstance( + custom_query.get(key), dict + ): + parsedquery[key].update(custom_query[key]) + continue + parsedquery[key] = custom_query[key] empty_query = False # filter bad term and operator in query @@ -96,6 +104,7 @@ def _makequery( if parsedquery["searchWithSolr"]["query"]: search_with_solr = True del parsedquery["searchWithSolr"] + if not empty_query: if search_with_solr: if "SearchableText" in parsedquery: @@ -116,8 +125,8 @@ def _makequery( results = catalog(**parsedquery) if ( getattr(results, "actual_result_count", False) - and limit # noqa - and results.actual_result_count > limit # noqa + and limit + and results.actual_result_count > limit ): results.actual_result_count = limit @@ -137,7 +146,7 @@ def clean_query_for_solr(self, query): portal_state = api.content.get_view( context=self.context, request=self.request, - name=u"plone_portal_state", + name="plone_portal_state", ) root_path = portal_state.navigation_root_path() path = self.extract_value(v)