beautypg.com

Retrieving keymatch settings, Changing keymatch settings – Google Search Appliance Administrative API Developers Guide: .NET User Manual

Page 36

background image

Google Search Appliance: Administrative API Developer’s Guide: .NET

36

Retrieving KeyMatch Settings

Retrieve KeyMatch settings as follows:

Dictionary queryMap = new Dictionary();

// Initialize the query map
queryMap.Add("query", "myQuery");
queryMap.Add("startLine", "0");
queryMap.Add("maxLines", "50");

// Send the request and print the response
GsaEntry myEntry = myService.QueryEntry("keymatch", "myFrontend", queryMap);
foreach(KeyValuePair kvp in myEntry.GetAllGsaContents()) {

if (Regex.IsMatch(kvp.Key, @"^\d+$")) {

Console.WriteLine("The lines for " + kvp.Key + " are: " + kvp.Value);

}

}
Console.WriteLine("The number of lines are: " + myEntry.GetGsaContent
("numLines"));

Changing KeyMatch Settings

The following example appends KeyMatch settings:

// Create an entry to hold properties to append
GsaEntry appendEntry = new GsaEntry();
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
myService.UpdateEntry("keymatch", "myFrontend", appendEntry);