Home
Home
German Version
Support
Impressum
25.3 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 - 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 Connections 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 - Mindbreeze InSpire Insight Apps in Salesforce
      • Whitepaper - Web Connector - Setting Up Advanced Javascript Usecases
    • Configuration
      • CAS_Authentication
      • 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 - External Query Service
      • 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 - 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 - Natural Language Question Answering (NLQA)
      • Whitepaper - SSO with Microsoft AAD or AD FS
      • 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
      • CIS Level 2 Hardening - Setting SELinux to Enforcing mode
      • Configuration - app.telemetry dashboards for usage analysis
      • Configuration - Usage Analysis
      • Deletion of Hard Disks
      • 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
    • 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
      • Development of a Query Expression Transformer
      • Development of Insight Apps
      • Embedding the Insight App Designer
      • Java API Interface Description
      • OpenAPI Interface Description
    • 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
    • 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

    Development of a Query Expression Transformer

    IntroductionPermanent link for this heading

    The Query Expression Transformer provides the functionality to transform Mindbreeze query requests arbitrarily. The functionality is provided by creating a plugin using the Mindbreeze Software Development Toolkit. The SDK generates a sample plugin that can be customized.

    PreparationPermanent link for this heading

    To build and create a plugin with the Mindbreeze Software Development Toolkit, the following software components are required:

    • Java SE Development Kit: Version 1.8 or later
    • Eclipse IDE for Java Developers

    Mindbreeze Software Development ToolkitPermanent link for this heading

    To create a plugin project for a Query Expression Transformer plugin, the creation script must be called with the following parameters:

    mesjavaplugin.<sh|bat> <Plugin Type> <Name> <Base Package>

    • Plugin Type: The plugin type must be queryexpressiontransformer.
    • Name: The name of the plugin can be chosen arbitrarily, but the name should not contain dots or special characters. In the index configuration, the plugin can be uploaded and configured with the specified name.
    • Base Package: The base package of the Java classes that are created. Can be chosen arbitrarily, but the name should not contain dots or special characters.

    Creating a pluginPermanent link for this heading

    Mindbreeze Software Development Toolkit creates a plugin project that is available under the specified name in the current directory.

    1. Import plugin project into Eclipse.

    2. A basic implementation of the plugin is available under the name <name>QueryExpressionTransformer.java.
    3. To build the plugin, build.bat (Microsoft Windows) or build.sh (Linux) must be called. A plugin with the name
      <name>-queryexpressiontransformer.zip is created.
    4. The plugin can be installed using the Mindbreeze configuration interface.
    5. To use the plugin, it must be configured in the index configuration under "Query Transformation Services". To do this, the transformer must first be selected from the drop-down menu and then added to the Query Transformation Services with "Add".

    1. The automatically generated plugin contains sample code for transforming queries. The sample plugin transforms queries that contain the words "DIN" and "A4"/ "A5"/ etc.. Such queries are transformed so that objects whose dimension metadata corresponds to the DIN standard are also found.

    A query like:

    Poster Cat DIN A4

    Transformed to:

    (Poster Cat DIN A4) OR (width:297 AND height:210)

    Below you can see an example search where an additional document is found by this query transformation.

    Transformation implementationPermanent link for this heading

    Implementation of the Request TransformationPermanent link for this heading

    To transform the request the method, transform must be implemented.

    This example is included in the generated code of the SDK and transforms the incoming query expression transformation request. It should be noted that the transformed query expression must finally be forwarded as a query expression transformation response.

    /*
    * This inherited method is the entry point for transforming queries.

    * */

    @Override
    public void transform(com.google.protobuf.RpcController rpcController,
                          QueryExprTransformationRequest request,
                              com.google.protobuf.RpcCallback<QueryExprTransformationResponse> done) {
            try {
                QueryExpr transformedQueryExpr = transformQueryExpr(request.getQueryExpr()); //transform the query

                //build response with transformed query

                
    QueryExprTransformationResponse.Builder responseBuilder = QueryExprTransformationResponse.newBuilder();
                responseBuilder.setQueryExpr(transformedQueryExpr);
                QueryExprTransformationResponse response = responseBuilder.build();
                done.run(response);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }

    We perform the actual transformation in the transformQueryExpr method. Here you can see that each type of query expression must be processed separately so that the final result is reassembled properly. Query expressions can be nested within each other and can form a deep tree structure. For transforming queries with such a tree structure, all child queries are processed recursively. The relevant code for this is found in the generated example within the transformOnlyFieldsOfMessage method and can also be reused for individual applications with little customization.

    /*
         * This Query Expression Transformer can only handle expressions of type EXPR_TERMS.
         * These are the kind of query that is generated for queries without any formatting like "cat poster din a4"
         * Handling for other kinds of query expressions can be added here.
         * It is important to always return a valid Query Expression, not doing so can lead to follow-up-errors
         * */
        QueryExpr transformQueryExpr(QueryExpr expr) {
            
    if (expr.getKind() == Kind.EXPR_TERMS) {
                
    return transformQueryExprTerms(expr);
            }


            
    //recursively iterate through child elements, visit each child element and call transformQueryExpr method again for child query expressions
            return (QueryExpr) transformOnlyFieldsOfMessage(expr);
        }

    In the implementation of transformQueryExprTerms from the generated example, you can see how the original query expression is first searched and manipulated. You can see more examples of creating new query expressions by looking at the unit tests.

        /*
        * Each kind of Query Expression will need to be handled slightly differently in order to transform the query appropriately.
        * This method contains logic to look for "din" and "a4" in the expression terms and perform the corresponding
        * transformation if the strings exist in the query.
        */
       QueryExpr transformQueryExprTerms(QueryExpr originalExpr) {
          
    if (originalExpr.getKind() != Kind.EXPR_TERMS) {
              
    throw new IllegalArgumentException("Expected kind to be \"EXPR_TERMS\" but was \"" + originalExpr.getKind() + "\"");
           }

          
    if (originalExpr.getTermsExpr() == null) {
              
    return originalExpr;
           }


           List<QueryExpr.Terms.Element> originalTerms = originalExpr.getTermsExpr().getElementList();

           String foundDinMarker = getDinMarkerIfInTerms(originalTerms);


          
    //don't transform if the text markers are not found
           if (foundDinMarker == null) {
              
    return originalExpr;
           }


          
    //build the new query
           QueryExpr heightMetadataSearchExpr = QueryExprHelper.labeled(HEIGHT_METADATA_NAME, QueryExprHelper.term(dinStandardToHeightMm.get(foundDinMarker)));
           QueryExpr widthMetadataSearchExpr = QueryExprHelper.labeled(WIDTH_METADATA_NAME, QueryExprHelper.term(dinStandardToWidthMm.get(foundDinMarker)));


          
    // In this example, we use 'OR' for the outside of the query to find additional results, which match the metadata
           // query while also including all results from the original query
           QueryExpr.Builder transformedQuery =
                   QueryExprHelper.or(

                           QueryExprHelper.terms(originalTerms),

                           QueryExprHelper.and(

                                   heightMetadataSearchExpr,

                                   widthMetadataSearchExpr))

                   .toBuilder();


          
    //always pass on the original unparsed expression
           copyOriginalUnparsedExpr(originalExpr, transformedQuery);

          
    return transformedQuery.build();
       }

    Download PDF

    • Development of a Query Expression Transformer

    Content

    • Introduction
    • Preparation
    • Creating a plugin
    • Transformation implementation

    Download PDF

    • Development of a Query Expression Transformer