diff --git a/doc/release-notes/11133-search-fix.md b/doc/release-notes/11133-search-fix.md new file mode 100644 index 00000000000..88962b70ea0 --- /dev/null +++ b/doc/release-notes/11133-search-fix.md @@ -0,0 +1,3 @@ +### Search fix when using AVOID_EXPENSIVE_SOLR_JOIN=true + +Dataverse v6.5 introduced a bug which causes search to fail for non-superusers in multiple groups when the AVOID_EXPENSIVE_SOLR_JOIN feature flag is set to true. This releases fixes the bug. diff --git a/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java index 493dbfcecc4..d50fbee681c 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java @@ -335,9 +335,13 @@ public SolrQueryResponse search( // ----------------------------------- // PERMISSION FILTER QUERY // ----------------------------------- - String permissionFilterQuery = this.getPermissionFilterQuery(dataverseRequest, solrQuery, onlyDatatRelatedToMe, addFacets); - if (!StringUtils.isBlank(permissionFilterQuery)) { - solrQuery.addFilterQuery(permissionFilterQuery); + String permissionFilterQuery = getPermissionFilterQuery(dataverseRequest, solrQuery, onlyDatatRelatedToMe, addFacets); + if (!permissionFilterQuery.isEmpty()) { + String[] filterParts = permissionFilterQuery.split("&q1="); + solrQuery.addFilterQuery(filterParts[0]); + if(filterParts.length > 1 ) { + solrQuery.add("q1", filterParts[1]); + } } /** @@ -1099,9 +1103,9 @@ private String buildPermissionFilterQuery(boolean avoidJoin, String permissionFi String query = (avoidJoin&& !isAllGroups(permissionFilterGroups)) ? SearchFields.PUBLIC_OBJECT + ":" + true : ""; if (permissionFilterGroups != null && !isAllGroups(permissionFilterGroups)) { if (!query.isEmpty()) { - query = "(" + query + " OR " + "{!join from=" + SearchFields.DEFINITION_POINT + " to=id}" + SearchFields.DISCOVERABLE_BY + ":" + permissionFilterGroups + ")"; + query = "(" + query + " OR " + "{!join from=" + SearchFields.DEFINITION_POINT + " to=id v=$q1})&q1=" + SearchFields.DISCOVERABLE_BY + ":" + permissionFilterGroups; } else { - query = "{!join from=" + SearchFields.DEFINITION_POINT + " to=id}" + SearchFields.DISCOVERABLE_BY + ":" + permissionFilterGroups; + query = "{!join from=" + SearchFields.DEFINITION_POINT + " to=id v=$q1}&q1=" + SearchFields.DISCOVERABLE_BY + ":" + permissionFilterGroups; } } return query;