Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Feb 12, 2024
1 parent 7a93a2d commit 627bb45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions config/dev/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
<field name="destinatari" type="string" indexed="true" stored="true" required="false" multiValued="true" termVectors="false" termPositions="false" termOffsets="false"/>
<field name="finanziatori" type="string" indexed="true" stored="true" required="false" multiValued="true" termVectors="false" termPositions="false" termOffsets="false"/>
<field name="materie" type="string" indexed="true" stored="true" required="false" multiValued="true" termVectors="false" termPositions="false" termOffsets="false"/>
<field name="apertura_bando" type="date" indexed="true" stored="true" required="false" multiValued="false" termVectors="false" termPositions="false" termOffsets="false"/>
<!-- plone6/volto -->
<field name="image_scales" type="string" indexed="false" stored="true" required="false" multiValued="false" termVectors="false" termPositions="false" termOffsets="false" />
<field name="image_field" type="string" indexed="false" stored="true" required="false" multiValued="false" termVectors="false" termPositions="false" termOffsets="false" />
Expand Down
19 changes: 14 additions & 5 deletions src/rer/solrpush/browser/querybuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


class QueryBuilder(BaseView):

def _makequery(
self,
query=None,
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit 627bb45

Please sign in to comment.