beautypg.com

Changing keymatch settings – Google Search Appliance Administrative API Developers Guide: Java User Manual

Page 36

background image

Google Search Appliance: Administrative API Developer’s Guide: Java

36

Changing KeyMatch Settings

The following example appends KeyMatch settings:

// Create an entry to hold properties to append
GsaEntry appendEntry = new GsaEntry();
appendEntry.setId("myFrontend");
appendEntry.addGsaContent("updateMethod", "append");

// Prepare new content
String newLines =

"image,KeywordMatch,http://images.google.com/,Google Image Search\n" +
"video,KeywordMatch,http://www.youtube.com/,Youtube\n" +
"rss feed,PhraseMatch,http://www.google.com/reader,Reader";

appendEntry.addGsaContent("newLines", newLines);

// Send the request to the search appliance
myClient.updateEntry("keymatch", "myFrontend", appendEntry);

The following example updates KeyMatch settings:

// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
updateEntry.setId("myFrontend");
updateEntry.addGsaContent("updateMethod", "update");

// Set the start line number
updateEntry.addGsaContent("startLine", 0);

// Provide the original content
String originalLines =

"image,KeywordMatch,http://images.google.com/,Google Image Search\n" +
"video,KeywordMatch,http://www.youtube.com/,Youtube\n" +
"rss feed,PhraseMatch,http://www.google.com/reader,Reader";

updateEntry.addGsaContent("originalLines", originalLines);

// Prepare new content
String newLines =

",,,\n" +
"video,KeywordMatch,http://video.google.com/,Video Search\n" +
"rss feed,PhraseMatch,http://www.example.com/,RSS example";

updateEntry.addGsaContent("newLines", newLines);

// Send the request to the search appliance
myClient.updateEntry("keymatch", "myFrontend", updateEntry);

Note: Delete a setting by changing the statement to three commas (,,,).