Skip to content

Commit b34e1fe

Browse files
committed
Step 3, of the performance improvement effort relying on a boolean "publicObject" flag for
published documents - now for logged-in users, AND with support for groups. Group support experimental, but appears to be working. #10554
1 parent bb33111 commit b34e1fe

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

src/main/java/edu/harvard/iq/dataverse/search/SearchServiceBean.java

+29-11
Original file line numberDiff line numberDiff line change
@@ -1081,22 +1081,40 @@ private String getPermissionFilterQuery(DataverseRequest dataverseRequest, SolrQ
10811081
// ----------------------------------------------------
10821082

10831083
// A quick speedup experiment (L.A.)
1084-
// - This ignores the group membership completely;
1085-
// so, not a production-ready fix, just a proof of concept,
10861084
// an attempt to replace an uber-expensive join on ALL the public
10871085
// documents with the "publicObject:true" flag, similarly to what we
10881086
// are doing for guest users, above, and only using
10891087
// the join to explicitly look up the (few) documents the user is
1090-
// directly authorized to see (once again, groups are ignored for now)
1088+
// directly authorized to see, by direct assignment or via
1089+
// group membership. Group support is very experimental still.
10911090
if (FeatureFlags.AVOID_EXPENSIVE_SOLR_JOIN.enabled()) {
1092-
StringBuilder sb = new StringBuilder();
1093-
1094-
sb.append(SearchFields.PUBLIC_OBJECT + ":" + true + " OR ");
1095-
sb.append("{!join from=" + SearchFields.DEFINITION_POINT + " to=id}" + SearchFields.DISCOVERABLE_BY + ":" + IndexServiceBean.getGroupPerUserPrefix() + au.getId());
1096-
String ret = sb.toString();
1097-
logger.info("Returning experimental query: "+ret);
1098-
return ret;
1091+
StringBuilder sb = new StringBuilder();
1092+
1093+
sb.append(SearchFields.PUBLIC_OBJECT + ":" + true + " OR ");
1094+
1095+
// An AuthenticatedUser should also be able to see all the content
1096+
// on which they have direct permissions:
1097+
solrQuery.setParam("q1", SearchFields.DISCOVERABLE_BY + ":" + IndexServiceBean.getGroupPerUserPrefix() + au.getId());
1098+
sb.append("{!join from=" + SearchFields.DEFINITION_POINT + " to=id v=$q1}");
1099+
1100+
// In addition to the user referenced directly, we will also
1101+
// add joins on all the non-public groups that may exist for the
1102+
// user:
1103+
Set<Group> groups = groupService.collectAncestors(groupService.groupsFor(dataverseRequest));
1104+
int groupCounter = 1;
1105+
for (Group group : groups) {
1106+
String groupAlias = group.getAlias();
1107+
if (groupAlias != null && !groupAlias.isEmpty() && !groupAlias.startsWith("builtIn")) {
1108+
groupCounter++;
1109+
solrQuery.setParam("q" + groupCounter, SearchFields.DISCOVERABLE_BY + ":" + IndexServiceBean.getGroupPrefix() + groupAlias);
1110+
sb.append(" OR ");
1111+
sb.append("{!join from=" + SearchFields.DEFINITION_POINT + " to=id v=$q" + groupCounter + "}");
1112+
}
10991113
}
1114+
String ret = sb.toString();
1115+
logger.info("Returning experimental query: " + ret);
1116+
return ret;
1117+
}
11001118
/**
11011119
* @todo all this code needs cleanup and clarification.
11021120
*/
@@ -1109,7 +1127,7 @@ private String getPermissionFilterQuery(DataverseRequest dataverseRequest, SolrQ
11091127
* @todo rename this from publicPlusUserPrivateGroup. Confusing
11101128
*/
11111129
// safe default: public only
1112-
String publicPlusUserPrivateGroup = publicOnly;
1130+
String publicPlusUserPrivateGroup = publicOnly;
11131131
// + (onlyDatatRelatedToMe ? "" : (publicOnly + " OR "))
11141132
// + "{!join from=" + SearchFields.GROUPS + " to=" + SearchFields.PERMS + "}id:" + IndexServiceBean.getGroupPerUserPrefix() + au.getId() + ")";
11151133

0 commit comments

Comments
 (0)