Skip to content

Commit

Permalink
configurable option to skip indexing of metadatavalues with restricti…
Browse files Browse the repository at this point in the history
…ve securitylevel
  • Loading branch information
floriangantner committed May 2, 2024
1 parent ad337d0 commit 3b19272
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ public void addDiscoveryFields(SolrInputDocument doc, Context context, Item item
}
}

Integer maxsecuritylevel = DSpaceServicesFactory
.getInstance()
.getConfigurationService()
.getIntProperty("discovery.index.securitylevel.maxlevel", 0);

List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(item.getType());
List<MetadataValue> mydc = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
for (MetadataValue meta : mydc) {
Expand All @@ -340,6 +345,11 @@ public void addDiscoveryFields(SolrInputDocument doc, Context context, Item item
continue;
}

// We are not indexing values with security level greater than the maximum value
if (meta.getSecurityLevel() != null && meta.getSecurityLevel() > maxsecuritylevel) {
continue;
}

if (StringUtils.equals(value, CrisConstants.PLACEHOLDER_PARENT_METADATA_VALUE)) {
if (toProjectionFields.contains(field) || toProjectionFields
.contains(unqualifiedField + "." + Item.ANY)) {
Expand Down
5 changes: 4 additions & 1 deletion dspace/config/modules/discovery.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ discovery.facet.namedtype.workflow.pooled = 004workflow\n|||\nWaiting for Contro
# Set the number of retry of a query when stale objects are found.
# Set to -1 if stale objects should be ignored. Set to 0 if you want to avoid extra query but take the chance to cleanup
# the index each time that stale objects are found. Default 3
discovery.removestale.attempts = 3
discovery.removestale.attempts = 3

# the maximum securitylevel of metadatavalues which is still indexed. All above are skipped
discovery.index.securitylevel.maxlevel = 0

0 comments on commit 3b19272

Please sign in to comment.