Query Manipulation Server 26.2
Query Manipulation Server Help

# Use an Expanded Request Cooker

An expanded request cooker is similar to a request cooker, but it modifies the action after QMS has processed rules and expanded the query according to those rules.

The request cooker is a Lua script that processes the action.

When you use an expanded request cooker, QMS applies whitelist, blacklist, and query text processing to the original action, and then sends the original action, the modified action, and the list of applied rules to the cooker. The cooker processes the query further, and then returns the final modified request.

The cooker must specify the whole action to use.

## Expanded Request Cooker Lua Scripts

The Lua script must provide a globally accessible `cook_expanded_request` function, which accepts three arguments:

- A string representation of the original request that QMS received.
- A string representation of the modified request after QMS applies any rules.
- A table of strings that lists the references of rules that were triggered by the original request.

The function must return a Lua table. The keys of this table are the parameter names to use in the action (the parameter names must be in lower case). The table values are the corresponding request values.

QMS loads the Lua script for every request that it cooks. This means that any changes to the script are reflected immediately in the query behavior.

You can use the Knowledge Discovery Lua libraries in your Lua scripts. For more information about the available functions and methods, see the QMS Reference.

The following example Lua script changes the value of MaxResults according to whether a particular rule was activated in the query, and adds additional query terms when other rules were activated.

    aci = require "lua/autn_aci"
    function cook_expanded_request(request, expanded_request, matched_rules)
       req = aci.parse_request_string(expanded_request)

       if matched_rules["fieldexpand"] ~= nil then
          req["maxresults"] = "10"
       else
          req["maxresults"] = "3"
       end

       if matched_rules["synonym1"] ~= nil then
          req["text"] = string.format("%s AND Spain", req["text"])
       end

       if matched_rules["finance"] ~= nil then
          req["text"] = string.format("%s OR money", req["text"])
       end

       return req
    end

## Configure the Expanded Request Cooker

The following procedure describes how to configure QMS to use a request cooker from an external service, or a Lua script.

To use a request cooker

1. Open the QMS configuration file in a text editor.

2. Add a `[ExpandedRequestCooker]` section to the QMS configuration file.

3. In the `[ExpandedRequestCooker]` section of the configuration file, set Script to the path to the script that you want to use. For example:

       [ExpandedRequestCooker]
       Script=qms\lua\cookrequest-maxresults.lua

4. Send queries to QMS with the CookRequest parameter set to `True`.

   If you want to cook all requests that you send to QMS, set the CookAllRequests configuration parameter to `True`.

   NOTE: When you set CookAllRequests to `True`, QMS] does not retrieve or process cardinal placements.

For more information on how to configure expanded request cooking, see Expanded Request Cooker Parameters.

Copyright 2026 Open Text
Version 26.2 | Last updated April 2026

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery Query Manipulation Server 26.2

Topic Title: Use an Expanded Request Cooker