Skip to content

Commit

Permalink
More robust search if schema not registered
Browse files Browse the repository at this point in the history
Do not break search if a record indexed is using a schema not available in the current installation.

Record with error are flagged with indexing error and will also log an error during search

```log
 Record is indexed indexing error flag.
2024-09-20T08:59:31,591 ERROR [geonetwork.datamanager] - Record 127 / Schema 'dcat-ap' is not registered in this catalog. Install it or remove those records. Record is indexed indexing error flag.

2024-09-20T09:00:04,688 ERROR [geonetwork.index] - Failed to load metadata schema for aa122105-7db3-4a4d-9887-0ced5c2ee6b5. Error is: Schema not registered : dcat-ap
```
  • Loading branch information
fxprunayre authored Sep 20, 2024
1 parent a04efca commit 02cabca
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions services/src/main/java/org/fao/geonet/api/es/EsHTTPProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,17 @@ private void processResponse(ServiceContext context, HttpSession httpSession,
ObjectNode sourceNode = (ObjectNode) doc.get("_source");

String metadataSchema = doc.get("_source").get(Geonet.IndexFieldNames.SCHEMA).asText();
MetadataSchema mds = schemaManager.getSchema(metadataSchema);

// Apply metadata schema filters to remove non-allowed fields
processMetadataSchemaFilters(context, mds, doc);

try {
MetadataSchema mds = schemaManager.getSchema(metadataSchema);

// Apply metadata schema filters to remove non-allowed fields
processMetadataSchemaFilters(context, mds, doc);
} catch (IllegalArgumentException e) {
LOGGER.error("Failed to load metadata schema for {}. Error is: {}",
getSourceString(doc, Geonet.IndexFieldNames.UUID),
e.getMessage()
);
}
// Remove fields with privileges info
for (ReservedOperation o : ReservedOperation.values()) {
sourceNode.remove("op" + o.getId());
Expand Down

0 comments on commit 02cabca

Please sign in to comment.