Use a Request Cooker

A request cooker is similar to a query cooker, but it modifies the whole action, rather than only the query text. For example, you can use a request cooker to add extra parameters to the query that users send to QMS.

You can configure the request cooker to be an external service, or you can use a Lua script.

When you use a request cooker, QMS sends the original action to the cooker. The cooker returns the modified request, and QMS applies whitelist, then blacklist, and then query text processing to it as necessary.

The cooker must specify the whole action to use.

Request Cooker Lua Scripts

The Lua script must provide a globally accessible cook_request function, which accepts a string representation of the request as its only argument. 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.

The following example request cooker Lua script sets MaxResults to 10 for all queries:

-- load module that provides string to table request parser
aci = require "autn_aci" 
-- Set maxresults to 10 on every query
function cook_request(request_string)
  cooked_request = aci.parse_request_string(request_string)
  cooked_request["maxresults"] = 10 
  return cooked_request

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

Configure the 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 [RequestCooker] section to the QMS configuration file.

  3. If you want to use a request cooker on an external server, specify the host and port information of the server and set Mode to legacy in the [RequestCooker] section of the configuration file. For example:

  4. If you want to use a custom Lua script for request cooking, set Mode to lua in the [RequestCooker] section of the configuration file, and set Script to the path to the script that you want to use. For example:

  5. 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.


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

Refer to the QMS Reference for more information on how to configure query cooking.