Skip to content

ScriptTagger and Nashorn engine #89

@danizen

Description

@danizen

I am updating my code to work under OpenJDK 11, as soon Oracle will stop supporting Java 8, and my institution, as government may be expected to do, is moving on.

After some adjustments, my tests mostly work, but I say the following error message"Warning: Nashorn engine is planned to be removed from a future JDK release" in a verify test that runs with the actual importer configuration I use in production. The problem I gather is the ScriptTagger.

JEP 335 states that the Nashorn engine will be removed from a future release. Long term, that's probably a good thing, but the ScriptTagger defaults to using the Nashorn engine, and so work should be done to find a better alternative default ECMA script implementation so that importer configurations similar to the following continue to work:

    <tagger class="com.norconex.importer.handler.tagger.impl.ScriptTagger">
      <script><![CDATA[
        /* create a domain field */
        var expr = new RegExp('[a-z]+://([^/]+).*');
        var url = metadata.url[0];
        var domain = url.replace(expr, '$1');
        metadata.addString('domain', domain);

        /* if keywords is not a list, make it one */
        if (metadata.containsKey('keywords')) {
           var keywords = metadata.get('keywords');
           if (typeof keywords == 'string') {
              metadata.set('keywords', [keywords])
           }
        }

        /* Clean the schemaorg_itemtype variables */
        if (metadata.containsKey('schemaorg_itemtype')) {
          var newdata = new java.util.ArrayList();
          var data = metadata.get('schemaorg_itemtype');
          for each (var datum in data) {
            newdata.add(datum.replaceFirst('^https?\://schema.org/', ''));
          }
          metadata.put('schemaorg_itemtype', newdata);
        }
      ]]></script>
    </tagger>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions