Setting Options Using CGI Parameters

Your users are going to want flexibility when making search queries using the search applications that you create using Watson™ Explorer Engine. To support this, we set some common project options based on the CGI parameters that are passed to the script query-meta.

All CGI parameters that are passed to the script become variables that can be manipulated by Watson Explorer Engine. Likewise, all options in a project are variables whose values can be specified by some XML code.

The Watson Explorer Engine XML Schema is almost as flexible as a programming language; you'll find it similar in some ways to XSL. It is this XML that we use to set options based on CGI parameters.

In a typical user interaction with the query-meta script, setting options and variables based on CGI parameters occurs after the project is loaded, when the macro node named core-main is processed (query-meta knows which macro to process from the value of the main variable that is found in the Advanced > Misc tab of a project).

Let's look at a simple example: specifying the list of sources the user's query should be submitted to. You'll see the following XML in the macro node core-main-cgi (which is referenced by core-main):

<if-var name="v:sources" realm="param" match="?*">
  <set-var name="query.sources">
    <value-of-var name="v:sources" realm="param" multi-sep=" " />
  </set-var>
</if-var>

This if-var statement is similar to an xsl:if statement in XSL. It tests for the existence of the v:sources CGI parameter, the parameter that by default specifies the sources to query. The realm attribute indicates that the variable v:sources is a CGI parameter and not an internal Watson Explorer Engine variable.

If v:sources is set, then it changes the value of the query.sources variable. Otherwise, it does nothing, and query.sources remains set to whatever value was specified in the current project. Because the source All is specified as the default value of the variable query.sources it is the default source to search, if no sources are specified in the v:sources CGI parameter.

To change this value in from the Components tab for a Project, click edit to the right of the Sources (default) label. The query.sources variable will initially have an empty box next to it, indicating that it will use the default value that is supplied in Watson Explorer Engine (which is All). Enter the name of a source, click OK, and it will become the default source to be searched for simple queries.

You can examine the core-main-cgi macro online to see all of the options that can be set by using XML. Remember that the online Schema documentation is an excellent reference when trying to understand how XML is processed in the Watson Explorer Engine software.