Home
Home
German Version
Support
Impressum
26.4 Release ►

Start Chat with Collection

    Main Navigation

    • Preparation
      • Connectors
      • Create an InSpire VM on Hyper-V
      • Initial Startup for G7 appliances
      • Setup InSpire G7 primary and Standby Appliances
    • Datasources
      • Configuration - Atlassian Confluence Connector
      • Configuration - Atlassian Confluence REST Connector
      • Configuration - Best Bets Connector
      • Configuration - Box Connector
      • Configuration - COYO Connector
      • Configuration - Data Integration Connector
      • Configuration - Database Connector
      • Configuration - Documentum Connector
      • Configuration - Dropbox Connector
      • Configuration - Egnyte Connector
      • Configuration - GitHub Connector
      • Configuration - Google Drive Connector
      • Configuration - GSA Adapter Service
      • Configuration - HL7 Connector
      • Configuration - IBM Lotus Connector
      • Configuration - Jira Connector
      • Configuration - JVM Launcher Service
      • Configuration - LDAP Connector
      • Configuration - Microsoft Azure Principal Resolution Service
      • Configuration - Microsoft Dynamics CRM Connector
      • Configuration - Microsoft Exchange Connector
      • Configuration - Microsoft File Connector (Legacy)
      • Configuration - Microsoft File Connector
      • Configuration - Microsoft Graph Connector
      • Configuration - Microsoft Loop Connector
      • Configuration - Microsoft Project Connector
      • Configuration - Microsoft SharePoint Connector
      • Configuration - Microsoft SharePoint Online Connector
      • Configuration - Microsoft Stream Connector
      • Configuration - Microsoft Teams Connector
      • Configuration - Salesforce Connector
      • Configuration - SCIM Principal Resolution Service
      • Configuration - SemanticWeb Connector
      • Configuration - ServiceNow Connector
      • Configuration - Web Connector
      • Configuration - Yammer Connector
      • Data Integration Guide with SQL Database by Example
      • Indexing user-specific properties (Documentum)
      • Installation & Configuration - Atlassian Confluence Sitemap Generator Add-On
      • Installation & Configuration - Caching Principal Resolution Service
      • Installation & Configuration - Mindbreeze InSpire Insight Apps in Microsoft SharePoint On-Prem
      • Mindbreeze InSpire Insight Apps in Microsoft SharePoint Online
      • Mindbreeze Web Parts for Microsoft SharePoint
      • User Defined Properties (SharePoint 2013 Connector)
      • Whitepaper - Migration of Sites Selected Permissions for the MS SharePoint Online Connector
      • Whitepaper - Migration of Tenant-Wide Permissions for the MS SharePoint Online Connector
      • Whitepaper - Mindbreeze InSpire Insight Apps in Salesforce
      • Whitepaper - Overview of Connectors
      • Whitepaper - Web Connector - Setting Up Advanced Javascript Usecases
    • Configuration
      • CAS_Authentication
      • Configuration - Advanced Configuration for Mail Delivery
      • Configuration - Alerts
      • Configuration - Alternative Search Suggestions and Automatic Search Expansion
      • Configuration - Back-End Credentials
      • Configuration - Chinese Tokenization Plugin (Jieba)
      • Configuration - CJK Tokenizer Plugin
      • Configuration - Collected Results
      • Configuration - CSV Metadata Mapping Item Transformation Service
      • Configuration - Entity Recognition
      • Configuration - Exporting Results
      • Configuration - Filter Plugins
      • Configuration - GSA Late Binding Authentication
      • Configuration - Identity Conversion Service - Replacement Conversion
      • Configuration - InceptionImageFilter
      • Configuration - Index-Servlets
      • Configuration - InSpire AI Chat and Insight Services for Retrieval Augmented Generation
      • Configuration - Item Property Generator
      • Configuration - Japanese Language Tokenizer
      • Configuration - JavaScript Transformer Plugins
      • Configuration - Kerberos Authentication
      • Configuration - Management Center Menu
      • Configuration - Metadata Enrichment
      • Configuration - Metadata Reference Builder Plugin
      • Configuration - Mindbreeze Proxy Environment (Remote Connector)
      • Configuration - Personalized Relevance
      • Configuration - Plugin Installation
      • Configuration - Principal Validation Plugin
      • Configuration - Profile
      • Configuration - Reporting Query Logs
      • Configuration - Reporting Query Performance Tests
      • Configuration - Request Header Session Authentication
      • Configuration - Shared Configuration (Windows)
      • Configuration - Vocabularies for Synonyms and Suggest
      • Configuration of Thumbnail Images
      • Cookie-Authentication
      • Documentation - Mindbreeze InSpire
      • I18n Item Transformation
      • Installation & Configuration - Outlook Add-In
      • Installation - GSA Base Configuration Package
      • JWT Authentication
      • Language detection - LanguageDetector Plugin
      • Mindbreeze Personalization
      • Mindbreeze Property Expression Language
      • Mindbreeze Query Expression Transformation
      • SAML-based Authentication
      • Trusted Peer Authentication for Mindbreeze InSpire
      • Using the InSpire Snapshot for Development in a CI_CD Scenario
      • Whitepaper - AI Chat
      • Whitepaper - Create a Google Compute Cloud Virtual Machine InSpire Appliance
      • Whitepaper - Create a Microsoft Azure Virtual Machine InSpire Appliance
      • Whitepaper - Create AWS 10M InSpire Appliance
      • Whitepaper - Create AWS 1M InSpire Appliance
      • Whitepaper - Create AWS 2M InSpire Appliance
      • Whitepaper - Create Oracle Cloud 10M InSpire Application
      • Whitepaper - Create Oracle Cloud 1M InSpire Application
      • Whitepaper - MMC_ Services
      • Whitepaper - Single Sign-On with Microsoft Entra ID or Active Directory Federation Services
      • Whitepaper - Text Classification Insight Services
    • Operations
      • Adjusting the InSpire Host OpenSSH Settings - Set LoginGraceTime to 0 (Mitigation for CVE-2024-6387)
      • app.telemetry Statistics Regarding Search Queries
      • Blacklisting vulnerable kernel modules esp4, esp6, rxrpc - (Mitigation for CVE-2026-43284 _ DirtyFrag)
      • CIS Level 2 Hardening - Setting SELinux to Enforcing mode
      • Configuration - app.telemetry dashboards for usage analysis
      • Configuration - Usage Analysis
      • Disabling algif_aead_init - (Mitigation for CVE-2026-31431)
      • FAQ - Creating Mindbreeze InSpire Appliances on Hyper Scalers
      • Handbook - Backup & Restore
      • Handbook - Command Line Tools
      • Handbook - Distributed Operation (G7)
      • Handbook - Filemanager
      • Handbook - Indexing and Search Logs
      • Handbook - Updates and Downgrades
      • Index Operating Concepts
      • Inspire Diagnostics and Resource Monitoring
      • Provision of app.telemetry Information on G7 Appliances via SNMPv3
      • Restoring to As-Delivered Condition
      • Whitepaper - Administration of Insight Services for Retrieval Augmented Generation
      • Whitepaper - Insight Workplace
      • Whitepaper - Mindbreeze in Microsoft Teams
      • Whitepaper - Mindbreeze in OpenAI ChatGPT
      • Whitepaper - Mindbreeze InSpire LLM_ A Kubernetes Integration Guide
      • Whitepaper - Mindbreeze InSpire LLM_ On-Premise Deployment Guide
      • Whitepaper - Natural Language Question Answering (NLQA)
      • Whitepaper - Overview AI based Document Parsing, Transcriptions, and Semantic Index Pipeline
      • Whitepaper - Overview of Agentic AI and the Insight Workplace
      • Whitepaper - Using the Mindbreeze InSpire MCP Server
    • User Manual
      • Browser Extension
      • Cheat Sheet
      • iOS App
      • Keyboard Operation
    • SDK
      • api.chat.v1beta.generate Interface Description
      • api.v2.alertstrigger Interface Description
      • api.v2.export Interface Description
      • api.v2.personalization Interface Description
      • api.v2.search Interface Description
      • api.v2.suggest Interface Description
      • api.v3.admin.SnapshotService Interface Description
      • Debugging (Eclipse)
      • Developing an API V2 search request response transformer
      • Developing Item Transformation and Post Filter Plugins with the Mindbreeze SDK
      • Developing Item Transformation Launched Service with Mindbreeze SDK
      • Development of a Query Expression Transformer
      • Development of Insight Apps
      • Embedding the Insight App Designer
      • Export and Integration of Personalization and Analytics Data with External Platforms
      • Java API Interface Description
      • OpenAPI Interface Description
      • SDK Overview
    • Release Notes
      • Release Notes 20.1 Release - Mindbreeze InSpire
      • Release Notes 20.2 Release - Mindbreeze InSpire
      • Release Notes 20.3 Release - Mindbreeze InSpire
      • Release Notes 20.4 Release - Mindbreeze InSpire
      • Release Notes 20.5 Release - Mindbreeze InSpire
      • Release Notes 21.1 Release - Mindbreeze InSpire
      • Release Notes 21.2 Release - Mindbreeze InSpire
      • Release Notes 21.3 Release - Mindbreeze InSpire
      • Release Notes 22.1 Release - Mindbreeze InSpire
      • Release Notes 22.2 Release - Mindbreeze InSpire
      • Release Notes 22.3 Release - Mindbreeze InSpire
      • Release Notes 23.1 Release - Mindbreeze InSpire
      • Release Notes 23.2 Release - Mindbreeze InSpire
      • Release Notes 23.3 Release - Mindbreeze InSpire
      • Release Notes 23.4 Release - Mindbreeze InSpire
      • Release Notes 23.5 Release - Mindbreeze InSpire
      • Release Notes 23.6 Release - Mindbreeze InSpire
      • Release Notes 23.7 Release - Mindbreeze InSpire
      • Release Notes 24.1 Release - Mindbreeze InSpire
      • Release Notes 24.2 Release - Mindbreeze InSpire
      • Release Notes 24.3 Release - Mindbreeze InSpire
      • Release Notes 24.4 Release - Mindbreeze InSpire
      • Release Notes 24.5 Release - Mindbreeze InSpire
      • Release Notes 24.6 Release - Mindbreeze InSpire
      • Release Notes 24.7 Release - Mindbreeze InSpire
      • Release Notes 24.8 Release - Mindbreeze InSpire
      • Release Notes 25.1 Release - Mindbreeze InSpire
      • Release Notes 25.2 Release - Mindbreeze InSpire
      • Release Notes 25.3 Release - Mindbreeze InSpire
      • Release Notes 25.4 Release - Mindbreeze InSpire
      • Release Notes 25.5 Release - Mindbreeze InSpire
      • Release Notes 25.6 Release - Mindbreeze InSpire
      • Release Notes 25.7 Release - Mindbreeze InSpire
      • Release Notes 25.8 Release - Mindbreeze InSpire
      • Release Notes 26.1 Release - Mindbreeze InSpire
      • Release Notes 26.2 Release - Mindbreeze InSpire
      • Release Notes 26.3 Release - Mindbreeze InSpire
      • Release Notes 26.4 Release - Mindbreeze InSpire
    • Security
      • Known Vulnerablities
    • Product Information
      • Product Information - Mindbreeze InSpire - Standby
      • Product Information - Mindbreeze InSpire
    Home

    Path

    Sure, you can handle it. But should you?
    Let our experts manage the tech maintenance while you focus on your business.
    See Consulting Packages

    Configuration
    JavaScript Transformer Plugins

    IntroductionPermanent link for this heading

    The JavaScript Transformer plugins provide a flexible scripting engine designed to customize the Semantic Pipeline. By leveraging this engine, users can inject custom logic into specific stages of the Semantic Pipeline using ECMAScript 2021.

    The framework consists of three specialized plugins:

    • Item Transformer
    • Post Filter Transformer
    • Query Expression Transformer

    The scripting engine supports calls to external services, such as LLM endpoints, allowing for the dynamic enrichment of data and behaviour via simple prompts.

    ConfigurationPermanent link for this heading

    Item TransformerPermanent link for this heading

    Configuration of the Item Transformer can be done with the following steps:

    Add the service “ItemTransformationServicePlugin.JavaScriptItemTransformer” to the Index configuration

    Configure the “JavaScript Code” property

    Sample JavaScript Code for Item TransformerPermanent link for this heading

    const Item = Java.type('mindbreeze.common.TypesProtos.Item');

    const ItemTransformationResponse = Java.type('mindbreeze.processing.ItemTransformationServiceProtos.ItemTransformationResponse');

    const ValueHelper = Java.type('com.mindbreeze.enterprisesearch.mesapi.protobuf.sdk.common.ValueHelper');

    const Logger = Java.type('org.apache.log4j.Logger');

    function transform(controller, request, done) {

        const item = Item.newBuilder(request.getItem());

        const result = myHelper(item);

        const responseBuilder = ItemTransformationResponse.newBuilder();

        responseBuilder.setItem(result);

        done.run(responseBuilder.build());

    }

    function myHelper(result) {

      const logger = Logger.getLogger("com.mindbreeze.javascriptitemtransformer.JavaScriptItemTransformationService");

      let key = result.getHeader().getKey();

      let category = result.getHeader().getCategory();

      logger.info("JS ItemTransformer.transform for item: " + category + "/" + key);

      for (let i = 0; i < result.getPropertyCount(); i++) {

    const property = result.getProperty(i);

    //logger.info("(" + i + ") found property with name: " + property.getName());

    if (property.getName() === "title") {

    for (let j = 0; j < property.getValueCount(); j++) {

    const value = property.getValue(j);

    title = value.getStringValue() || "";

    //logger.info("title: " + title);

    }

    }

    }

    const myTitleProperty = TypesProtos.NamedValue.newBuilder().setName("myTitle");

    myTitleProperty.addValue(ValueHelper.newBuilder("MY___" + title));

    logger.info("myTitle: " + "MY___" + title);

    result.addProperty(myTitleProperty);

        return result;

    }

    Post Filter TransformerPermanent link for this heading

    Configuration of the Post Filter Transformer can be done with the following steps:

    Add the PostFilterPlugin.JavaScriptPostFilterTransformationService to the Filter Service configuration

    Configure the “JavaScript Code Path” property

    Sample for Post Filter TransformerPermanent link for this heading

    const Logger = Java.type('org.apache.log4j.Logger');

    const FilterAndIndexRequest =  Java.type('mindbreeze.filter.FilterServiceProtos.FilterAndIndexRequest');

    const NamedValue = Java.type('mindbreeze.common.TypesProtos.NamedValue');

    const ValueHelper = Java.type('com.mindbreeze.enterprisesearch.mesapi.protobuf.sdk.common.ValueHelper');

    const MetadataOrBuilder = Java.type('mindbreeze.common.MetadataProtos.MetadataOrBuilder');

    const logger = Logger.getLogger("com.mindbreeze.javascript.JavaScriptPostFilterTransformationService");

    function transform(controller, request, done) {

        try {

            const responseBuilder = FilterAndIndexRequest.newBuilder(request);

            const metadataBuilder = responseBuilder.getContentBuilder().getMetadataBuilder();

            const namedValueBuilder = NamedValue.newBuilder();

            namedValueBuilder.setName("postfiltertest");

            namedValueBuilder.addValue(ValueHelper.newBuilder("Test-success"));

            metadataBuilder.addMetadatum(namedValueBuilder);

            logger.info("Adding Metadata: " + namedValueBuilder);

            done.run(responseBuilder.build());

        } catch (e) {

            logger.error("Error in JS Post Filter Code: " + e);

        }

    }

    Query Expression TransformerPermanent link for this heading

    Configuration of the Query Expression Transformer can be done with the following steps:

    Add the JavaScriptQueryExprTransformationService to the Index Service configuration

    Configure the “JavaScript Code Path” property

    Sample for Query Expression TransformerPermanent link for this heading

    const QueryExprTransformationResponse = Java.type('mindbreeze.query.QueryExprTransformationServiceProtos.QueryExprTransformationResponse');

    const QueryExprProtos = Java.type('mindbreeze.query.QueryExprProtos');

    const Logger = Java.type('org.apache.log4j.Logger');

    const logger = Logger.getLogger("com.mindbreeze.javascript.JavaScriptQueryExprTransformationService");

    const metadataToRewrite = ["SearchableMetadata"];

    function transformQueryExpr(queryExpr, options) {

      options = options || {};

      const builder = QueryExprProtos.QueryExpr.newBuilder(queryExpr);

      

      switch (queryExpr.getKind().toString()) {

        case 'EXPR_NOT':

          const notExprBuilder = QueryExprProtos.QueryExpr.Not.newBuilder(queryExpr.getNotExpr());

          notExprBuilder.setInitialExpr(transformQueryExpr(notExprBuilder.getInitialExpr(), options));

          for (let i=0; i < notExprBuilder.getExcludedExprCount(); i++) {

            notExprBuilder.setExcludedExpr(i, transformQueryExpr(notExprBuilder.getExcludedExpr(i), options));

          }

          builder.setNotExpr(notExprBuilder);

          break;

          

        case 'EXPR_AND':

          const andExprBuilder = QueryExprProtos.QueryExpr.And.newBuilder(queryExpr.getAndExpr());

          for (let i=0; i < andExprBuilder.getExprCount(); i++) {

            andExprBuilder.setExpr(i, transformQueryExpr(andExprBuilder.getExpr(i), options));

          }

          builder.setAndExpr(andExprBuilder);

          break;

          

        case 'EXPR_OR':

          const orExprBuilder = QueryExprProtos.QueryExpr.Or.newBuilder(queryExpr.getOrExpr());

          for (let i=0; i < orExprBuilder.getExprCount(); i++) {

            orExprBuilder.setExpr(i, transformQueryExpr(orExprBuilder.getExpr(i), options));

          }

          builder.setOrExpr(orExprBuilder);

          break;

          

        case 'EXPR_LABELED':

          const namedExprBuilder = QueryExprProtos.QueryExpr.Labeled.newBuilder(queryExpr.getNamedExpr());

          

          if (metadataToRewrite.indexOf(namedExprBuilder.getLabel()) >= 0) {

            namedExprBuilder.setExpr(transformQueryExpr(namedExprBuilder.getExpr(), { rewriteToRegex: true }));

          }

          builder.setNamedExpr(namedExprBuilder);

          break;

          

        case 'EXPR_ALL':

          if (options.rewriteToRegex) {

            return QueryExprProtos.QueryExpr.newBuilder()

                  .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_REGEX_PATTERN)

                  .setRegexPattern(".+");

          }

          break;

          

        case 'EXPR_TERM':

          if (options.rewriteToRegex) {

            return QueryExprProtos.QueryExpr.newBuilder()

                  .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_REGEX_PATTERN)

                  .setRegexPattern("\\b\\Q" + queryExpr.getTerm() + "\\E");

          } else {

            return queryExpr;

                  return QueryExprProtos.QueryExpr.newBuilder()

                    .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_OR)

                    .setOrExpr(

                      QueryExprProtos.QueryExpr.Or.newBuilder()

                        .addExpr(queryExpr)

                      )

          }

          break;

          

        case 'EXPR_TERMS':

          if (options.rewriteToRegex) {

          let termsExprBuilder = QueryExprProtos.QueryExpr.And.newBuilder();

          for (let i=0; i<queryExpr.getTermsExpr().getElementCount(); i++) {

            const term = queryExpr.getTermsExpr().getElement(i).getText();

            switch (queryExpr.getTermsExpr().getElement(i).getKind().toString()) {

              case "ELEMENT_PHRASE":

                termsExprBuilder.addExpr(

                  transformQueryExpr(

                    QueryExprProtos.QueryExpr.newBuilder()

                      .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_QUOTED_TERM)

                      .setQuotedTerm(term)

                      .build()

                  )

                );

                break;

                

              case "ELEMENT_TERM":

                termsExprBuilder.addExpr(

                  transformQueryExpr(

                    QueryExprProtos.QueryExpr.newBuilder()

                      .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_TERM)

                      .setTerm(term)

                      .build()

                  )

                );

                break;

                

              default:

              logger.warn("terms expr type '" + queryExpr.getTermsExpr().getElement(i).getKind().toString() + "' not handled");

              break;

            }

          }

          

          return QueryExprProtos.QueryExpr.newBuilder()

                        .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_AND)

                        .setAndExpr(termsExprBuilder)

            

          return QueryExprProtos.QueryExpr.newBuilder()

                .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_OR)

                .setOrExpr(

                  QueryExprProtos.QueryExpr.Or.newBuilder()

                    .addExpr(queryExpr)

                    .addExpr(

                      QueryExprProtos.QueryExpr.newBuilder()

                        .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_AND)

                        .setAndExpr(termsExprBuilder)

                    )

                )

          } else {

            return queryExpr;

          }

          

          

          break;

          

        case 'EXPR_QUOTED_TERM':

          if (options.rewriteToRegex) {

            return QueryExprProtos.QueryExpr.newBuilder()

                  .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_REGEX_PATTERN)

                  .setRegexPattern("\\b\\Q" + queryExpr.getQuotedTerm() + "\\E\\b");

          } else {

                  return QueryExprProtos.QueryExpr.newBuilder()

                    .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_OR)

                    .setOrExpr(

                      QueryExprProtos.QueryExpr.Or.newBuilder()

                        .addExpr(queryExpr)

                        .addExpr(

                          QueryExprProtos.QueryExpr.newBuilder()

                            .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_LABELED)

                            .setNamedExpr(

                              QueryExprProtos.QueryExpr.Labeled.newBuilder()

                                .setLabel("SearchableMetadata")

                                .setExpr(

                                  QueryExprProtos.QueryExpr.newBuilder()

                                    .setKind(QueryExprProtos.QueryExpr.Kind.EXPR_REGEX_PATTERN)

                                    .setRegexPattern("\\b\\Q" + queryExpr.getQuotedTerm() + "\\E\\b")

                                )

                            )

                        )

                      )

          }

          break;

            

        default:

          logger.warn("query expr type '" + queryExpr.getKind().toString() + "' not handled");

          break;

      }

      

      return builder.build();

    }

    function transform(controller, request, done) {

        try {

            const responseBuilder = QueryExprTransformationResponse.newBuilder();

            const transformedQueryExpr = transformQueryExpr(request.getQueryExpr());

            responseBuilder.setQueryExpr(transformedQueryExpr);

            response = responseBuilder.build();

            done.run(response);

        } catch (e) {

            logger.error("error: " + e);

        }

    }

    Download PDF

    • Configuration - JavaScript Transformer Plugins

    Content

    • Introduction
    • Configuration

    Download PDF

    • Configuration - JavaScript Transformer Plugins