Skip to content

Evaluators

Marten edited this page Apr 29, 2022 · 2 revisions

Geoportal accepts many flavors of XML or JSON as the base document containing metadata. Because these can all have different schemas, we extract common information into specific elastic fields that are indexed/managed by elastic specifically for use in search facets.

The place in the Geoportal where this information extraction happens is in the Evaluators. These evaluators are JavaScript code that is run on the server whenever a new document is pushed to the Geoportal through one of the publication mechanisms (harvesting, upload, editing, or even external scripts that use the Geoportal Server API).

The evaluators start with Evaluator.js that loads the different evaluators for the individual metadata schemas (for example: EvaluatorFor_ISO.js).

If you create a new metadata schema in Geoportal or you want to extract additional info from metadata in one of the existing schemas, you will need to add the extraction rules to the appropriate evaluator.

You will find code like this:

    G.evalProps(task,item,root,"contact_people_s","//gmd:CI_ResponsibleParty/gmd:individualName/*/text()");

This specific rule extracts the gmd:individualName value from a gmd:CI_ResponsibleParty element anywhere in the metadata and puts it in the elastic field contact_people_s.

In metadata standards such as those from ISO, the use of XML Namespaces is quite comment. These namespaces unambiguously define an element (such as title to a specific domain (the namespace)). This means that a record that includes dc:title and gmd:title still can be understood as dc and gmd represent (as namespace prefix) two different domains.

To declare namespaces in the evaluators, edit Evaluator.js and include in the function G._initializeTask lines such as the below:

  nsmap.put("dc","http://purl.org/dc/elements/1.1/");

Here dc is the namespace prefix and http://purl.org/dc/elements/1.1/ is the namespace URI.

Declaring the namespace then allows for the G.evalProps function to include xpath expressions that use the defined namespace prefixes.

Clone this wiki locally