Using the Google Search Appliance Simulator
The Google OneBox for Enterprise SDK includes a Python-based simulator that facilitates enterprise search simulations. The Python simulator acts in proxy for Google Search Appliance and the OneBox facilities.
After downloading the
Google OneBox for Enterprise SDK, download the
distribution of Python appropriate for your platform.
The Python simulator is OneBox-enabled with an XML file compliant with the schema found in
onebox.xsd of the OneBox for Enterprise SDK. The simulator accepts queries from a Python command line, which it passes to each OneBox module configured in the
onebox.xsd-compliant XML file.
Because the
onebox.xml file complies with the
onebox.xsd schema, you can use it to configure the simulator. This file, defined roughly as follows, contains a single OneBox module definition named "directory_onebox."
<GoogleEnterpriseSources
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<onebox type="external">
<name>
directory_onebox
</name>
<description>
This is a sample OneBox module that queries
for directory information.
</description>
<security userAuth="none"/>
<trigger triggerType="null"/>
<providerURL>
http://localhost:8080/onebox/SampleNoAuthOneBoxProvider
</providerURL>
<resultsTemplate>
<!-- contents removed for the sake of brevity -->
</resultsTemplate>
</onebox>
</GoogleEnterpriseSources>
After installing the Google OneBox for Enterprise SDK, you can run the Python simulator to process queries as a proxy for an actual Google Search Appliance. You start the Google Search Appliance with this command line:
<OneBoxSDK_install_dir>python onebox_simulator.py
onebox.xml --dumpOutput=1 --debug=1
In the preceding command, remember to replace
with the full directory name of your OneBox SDK installation. Running the simulator with the
dumpOutput=1 option combines the OneBox results with simulator's search results. The simulator generates search results from the
search.xml file, also distributed with the SDK.
To test it, enter this sample query from the Python command line:
query: Brown
After you enter the query, the simulator transmits a request to the URL specified in the
providerURL element of each module definition from the
onebox.xml file.
The preceding query yields results similar to
Listing 1.
In
Listing 1, the results returned from the simulator query contain an XML document immediately following the line reading "printed it as." Copy this XML document and apply the
gsa_default_stylesheet.en.xsl stylesheet, found in the Google OneBox for Enterprise SDK, to the document using any XML development tool.
Now, here's a sample query from a web browser using:
http://localhost:8080/onebox/SampleNoAuthOneBoxProvider?authType=
none&apiMaj=1&apiMin=2&lang=en&query=Brown
The preceding Web browser query yields the results shown in
Listing 2.
 | |
Figure 2. Query Results in HTML: After applying the default stylesheet to the XML results returned from the simulator using the "Brown" query, here's the resulting HTML. |
When you apply the default stylesheet (
gsa_default_stylesheet.en.xsl) against the preceding results document and save the result as HTML, the resulting page looks like
Figure 2.
You can customize the display by editing the
onebox-default.xsl (which is ultimately called from
gsa_default_stylesheet.en.xsl) and re-apply the stylesheet,
gsa_default_stylesheet.en.xsl, against the results in your XML development tool to see the changes. When you are satisfied with the transformed results, paste the XSL file contents, after the
element into your OneBox module definition XML file as the body of the
element.