Product Selector

Fusion 5.9
    Fusion 5.9

    Custom JavaScript stages for query pipelines

    The JavaScript Query stage allows you to write custom processing logic using JavaScript to manipulate search requests and responses. The first time that the pipeline is run, Managed Fusion compiles the JavaScript program into Java bytecode using the JDK’s JavaScript engine.

    The JavaScript Query stage allows you to run JavaScript functions over search requests and responses by manipulating variables called "request" and "response" which are Request objects and Response objects, respectively.

    Users who can create or modify code obtain access to the broader Managed Fusion environment. This access can be used to create intentional or unintentional damage to Managed Fusion.

    The JavaScript engine used by Managed Fusion

    The default JavaScript engine used by Managed Fusion is the Nashorn engine from Oracle. See The Nashorn Java API for details.

    In Managed Fusion 5.9.6 and up, you also have the option to select OpenJDK Nashorn. While Nashorn is the default option, it is in the process of being deprecated and will eventually be removed, so it is recommended to use OpenJDK Nashorn when possible. You can select the JavaScript engine in the pipeline views or in the workbenches. Your JavaScript pipeline stages are interpreted by the selected engine.

    JavaScript engine selector

    The GraalVM engine from Oracle is also available. Select GraalVM from the JavaScript engine dropdown to use it. See GraalVM for details. GraalVM works in Nashorn compatibility mode and should not be used in production. Full backwards compatibility is not available.

    Additional resources

    Lucidworks offers free training to help you get started.

    The Course for JavaScript in Fusion focuses on how to leverage JavaScript in Fusion to build powerful and responsive scripts at index and query time:

    JavaScript in Fusion

    Visit the LucidAcademy to see the full training catalog.