Retrieving related queries, Changing related queries – Google Search Appliance Administrative API Developers Guide: Java User Manual
Page 39

Google Search Appliance: Administrative API Developer’s Guide: Java
39
Retrieving Related Queries
Retrieve related queries as follows:
Map
// Initialize the query map
queryMap.put("query", "myQuery");
queryMap.put("startLine", "0");
queryMap.put("maxLines", "50");
// Send the request and print the response
GsaEntry myEntry = myClient.getEntry("synonym", "myFrontend", queryMap);
Iterator i = myEntry.getAllGsaContents().entrySet().iterator();
while (i.hasNext()) {
Map.Entry me = (Map.Entry)i.next();
if (me.getKey().matches("\\d+"))
{
System.out.println("The line " + my.getKey() + " is: " + my.getValue());
}
}
Note: maxLines is a required parameter. You can change the value of maxLines depending on the
number of entries you want returned. There is currently no method for returning all entries.
Changing Related Queries
The following example appends related queries:
// Create an entry to hold properties to append
GsaEntry appendEntry = new GsaEntry();
appendEntry.setId("myFrontend");
appendEntry.addGsaContent("updateMethod", "append");
// Prepare new content
String newLines = "airplane,aircraft\n" + "google,googol\n" + "stock,security";
appendEntry.addGsaContent("newLines", newLines);
// Send the request to the search appliance
myClient.updateEntry("synonym", "myFrontend", appendEntry);