Administrative API Developer’s Guide: .NET
Introduction
Before using the Google Search Appliance Administrative API, read Getting Started to download and configure required software.
Note: This guide uses data source feed to indicate the search appliance’s Feeds API (described in the Feeds Protocol Developer’s Guide).
•
|
•
|
•
|
Getting Started
The google-enterprise-gdata-api open source site (https://code.google.com/p/google-enterprise-gdata-api) provides ZIP files that contain sample C#.NET example files, the .NET client library (DLLs), source code, and a sample application for your reference.
Before starting, you need the following:
•
|
Microsoft Visual C# 2008 Express Edition (http://www.microsoft.com/exPress/download/#webInstall), which includes a free version of Visual Studio so that you can work with the .NET client library.
|
•
|
Getting Samples
After you download the software and acquire search appliance credentials, get started as follows:
1.
|
Unzip the API ZIP file and navigate to the cs folder. The client library DLL files are present in the lib folder and the sample application is present in the sample folder.
|
2.
|
Start Microsoft Visual C# 2008 Express Edition and click File > Open Project, browse to the location where you stored the gsa.sln solution file, and open the solution file, which appears in the Solution Explorer.
|
3.
|
Click Build > Build Solution to build the project. Ensure that the build runs without errors. The binaries and DLL files are put in the cs\sample\bin \Release folder. The output binary is the GsaCommandLine.exe executable file in the Release folder.
|
C:\GoogleDataAdministrativeAPI\cs\sample\bin\Release>GsaCommandLine.exe
Usage: GsaCommandLine <command> <options> <query_parameters> feed entry
commands:
retrieve
update
insert
delete
options:
--protocol:
--hostname:
--port:
--username:
--password:
--input: The input entry file for insert/update
<query_parameters>:
All the query parameters can be specified by --<query>=<value>
Example:
GsaCommandLine retrieve --protocol=http --hostname=gsa1 --port=8000
--username=user --password=password config crawlURLs
C:\GoogleDataAdministrativeAPI\API-Gdata\cs\sample\bin\Release>
Building Your Applications
1.
|
Copy the following client library DLL files from the cs\lib folder to your development folder and add them in the reference path:
|
3.
|
4.
|
Click the Browse tab and navigate to the folder where you copied the DLL files.
|
Authenticating Your Google Search Appliance Account
Before making API calls with the .NET client library, you must construct a new GsaService object.
In the constructor that follows, replace myUserId and myPassword with your Admin Console authentication information:
using Google.GData.Gsa;
GsaService myService = new GsaService(gsaAddr, gsaPort, "myUserId",
"myPassword"));
Content Sources
The sections that follow describe how to configure the Content Sources features of the Admin Console:
Crawl URLs
Retrieve and update crawl URL patterns on a search appliance using the crawlURLs entry of the config feed.
Start crawling from the following URLs, separate multiple URL patterns with new line delimiters. |
Retrieving Crawl URLs
Retrieve information about the URL patterns that the search appliance is crawling as follows:
// Send a request and print the response
GsaEntry myEntry = myService.GetEntry("config", "crawlURLs");
Console.WriteLine("Start URLs: " + myEntry.GetGsaContent("startURLs"));
Console.WriteLine("Follow URLs: " + myEntry.GetGsaContent("followURLs"));
Console.WriteLine("Do Not Crawl URLs: " + myEntry.GetGsaContent
("doNotCrawlURLs"));
Updating Crawl URLs
Update the crawl URL settings on a search appliance as follows—in the example that follows, example.com is requested for crawling, and spreadsheets are requested to not be crawled.
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property for adding crawl URLs to updateEntry
updateEntry.AddGsaContent("startURLs", "http://www.example.com/");
updateEntry.AddGsaContent("followURLs", "http://www.example.com/");
updateEntry.AddGsaContent("doNotCrawlURLs", ".xls$");
// Send the request
myService.UpdateEntry("config", "crawlURLs", updateEntry);
Data Source Feeds
Retrieve, delete, and destroy data source feed information for the search appliance using the feed feed. The following parameters let you search for a string and retrieve source statements.
The query string. When used to retrieve all feed information, the query parameter is overloaded to mean the feedDataStore. When getting information about a single feed, the parameter is a query. Each log statement contains a query string to be retrieved. |
|
The starting log statement to retrieve. The default value is line 1. |
|
The maximum number of log statements to retrieve. The default value is 50 statements. |
Use the following properties to view data source feed records and content.
The number of documents that had errors and were not added to the data source feed. |
|
Feed state: ACCEPTED:0, IN_PROGRESS:1, COMPLETED:2, COMPLETED_WITH_ERROR:3, FAILED_IN_ERROR:4 |
|
The system’s time stamp at the start of each stage, in milliseconds. |
|
Feed type: FULL_FEED:0, INCREMENTAL:1, DELETED:2, METADATA_AND_URL:3 |
|
Indicate to delete a data source feed. This value can only be delete. |
Retrieving Data Source Feed Information
Retrieve all data source feed information from a search appliance using the feed feed:
// Send a request and print the response
Dictionary<string, string> queries = new Dictionary<string, string>();
queries.Add("query",feedDataSource);
GsaFeed myFeed = myService.QueryFeed("feed", queries);
foreach(GsaEntry myEntry in myFeed.Entries) {
//get information on each myEntry
Console.WriteLine("Feed Name: " + myEntry.GetGsaContent("entryID"));
Console.WriteLine("Feed Data Source: " + myEntry.GetGsaContent
("feedDataSource"));
Console.WriteLine("Feed Type: " + myEntry.GetGsaContent("feedType"));
Console.WriteLine("Feed State: " + myEntry.GetGsaContent("feedState"));
Console.WriteLine("Feed Time: " + myEntry.GetGsaContent("feedTime"));
Console.WriteLine("Error Records: " + myEntry.GetGsaContent("errorRecords"));
Console.WriteLine("Success Records: " + myEntry.GetGsaContent
("successRecords"));
Console.WriteLine("Log Content: " + myEntry.GetGsaContent("logContent"));
}
You can get the individual feed information from a search appliance as follows:
GsaEntry myEntry = myService.GetEntry("feed", FEED_NAME);
Console.WriteLine("Feed Data Source: " + myEntry.GetGsaContent
("feedDataSource"));
Console.WriteLine("Feed Type: " + myEntry.GetGsaContent("feedType"));
Console.WriteLine("Feed State: " + myEntry.GetGsaContent("feedState"));
Console.WriteLine("Feed Time: " + myEntry.GetGsaContent("feedTime"));
Console.WriteLine("Error Records: " + myEntry.GetGsaContent("errorRecords"));
Console.WriteLine("Success Records: " + myEntry.GetGsaContent("successRecords"));
Console.WriteLine("Log Content: " + myEntry.GetGsaContent("logContent"));
Note: A feed log of all data source feeds can be retrieved only by getting individual feeds.
Deleting Data Source Feeds
Delete data source feeds as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property to updateEntry
updateEntry.AddGsaContent("updateMethod", "delete");
myService.UpdateEntry("feed", FEED_NAME, updateEntry);
Note: Delete data source feeds only of the type FULL_FEED or incremental. After deleting a data source feed, the deleted feed still exists, and the feed type changes to DELETED.
Destroying Data Source Feeds
myService.DeleteEntry("feed", FEED_NAME);
Trusted Feed IP Addresses
Retrieve and update trusted feed IP addresses using the feedTrustedIP entry of the config feed.
Retrieve the IP addresses of trusted feeds using the trustedIPs property.
Trusted IP addresses. This value is a list of one or more IP addresses. Specify all to indicate that the search appliance trust all IP addresses. If the value is a list of IP addresses, separate each IP address with white space. |
Retrieving Trusted Feed IP Addresses
Retrieve the trusted feed IP addresses as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("config ", "feedTrustedIP");
Console.WriteLine("Trusted IP Addresses: " +
myEntry.GetGsaContent("trustedIPs"));
Updating Trusted Feed IP Addresses
Update trusted feed IP addresses as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property for the feeds trusted IP addresses
// to updateEntry
updateEntry.AddGsaContent("trustedIPs", "127.0.0.1");
// Send the request
myService.UpdateEntry("config", "feedTrustedIP", updateEntry);
Crawl Schedule
Retrieve and update the crawl schedule for a search appliance.
The crawl schedule is only available in scheduled crawl mode. The value of crawlSchedule has the format: Day,Time,Duration
|
|||||||
Set to 1 if the search appliance is in scheduled crawl mode or set to 0 if the search appliance is in continuous crawl mode. |
Retrieving the Crawl Schedule
Retrieve the crawl mode and get the crawl schedule as follows:
GsaEntry myEntry = myService.GetEntry("config", "crawlSchedule");
Console.WriteLine("Is Scheduled Crawl: " + myEntry.GetGsaContent
("isScheduledCrawl"));
Console.WriteLine("Crawl Schedule: " + myEntry.GetGsaContent("crawlSchedule"));
Updating the Crawl Schedule
Update the crawl schedule or crawl mode as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property to updateEntry
updateEntry.AddGsaContent("isScheduledCrawl", "1");
updateEntry.AddGsaContent("crawlSchedule", "0,0300,360\n2,0000,1200");
// Send the request
myService.UpdateEntry("config", "crawlSchedule", updateEntry);
Crawler Access Rules
Create, retrieve, update, and delete crawler access rules for a search appliance.
Crawler access rules instruct the crawler how to authenticate when crawling the protected content.
Windows domain for NTLM, or empty for HTTP Basic authorization. |
|
Indicates whether to allow users to view results of both the public content (normally available to everyone) and the secure (confidential) content. The value can be 1 to enable users to view content as public, or 0 to require users to authenticate to view secure content. |
|
Inserting a Crawler Access Rule
Insert a new crawler access rule as follows:
// Create an entry to hold properties to insert
GsaEntry insertEntry = new GsaEntry();
// Add properties to insertEntry
insertEntry.AddGsaContent("entryID", "#URL pattern for the new crawler access
rule");
insertEntry.AddGsaContent("domain", "domainone");
insertEntry.AddGsaContent("isPublic", "1");
insertEntry.AddGsaContent("username", "username");
insertEntry.AddGsaContent("password", "password");
// Send the request
myService.InsertEntry("crawlAccessNTLM", insertEntry);
Retrieving Crawler Access Rules
Retrieve a list of crawler access rules as follows:
// Send a request and print the response
GsaFeed myFeed = myService.GetFeed("crawlAccessNTLM");
foreach(GsaEntry myEntry in myFeed.Entries) {
Console.WriteLine("URL Pattern: " + myEntry.GetGsaContent("urlPattern"));
Console.WriteLine("User Name: " + myEntry.GetGsaContent("username"));
Console.WriteLine("Order: " + myEntry.GetGsaContent("order"));
Console.WriteLine("Domain: " + myEntry.GetGsaContent("domain"));
Console.WriteLine("Is Public: " + myEntry.GetGsaContent("isPublic"));
}
Retrieve an individual crawler access rule as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("crawlAccessNTLM", "urlPattern");
Console.WriteLine("URL Pattern: " + myEntry.GetGsaContent("urlPattern"));
Console.WriteLine("User Name: " + myEntry.GetGsaContent("username"));
Console.WriteLine("Order: " + myEntry.GetGsaContent("order"));
Console.WriteLine("Domain: " + myEntry.GetGsaContent("domain"));
Console.WriteLine("Is Public: " + myEntry.GetGsaContent("isPublic"));
Note: The password property doesn’t appear when retrieving crawler access rules.
Updating a Crawler Access Rule
Update a crawler access rule as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add properties to updateEntry
updateEntry.AddGsaContent("urlPattern", "#new URL pattern");
updateEntry.AddGsaContent("domain", "newdomain");
updateEntry.AddGsaContent("isPublic", "0");
updateEntry.AddGsaContent("order", "2");
updateEntry.AddGsaContent("username", "newuser");
updateEntry.AddGsaContent("password", "newpass");
// Send the request
myService.UpdateEntry("crawlAccessNTLM", "urlPattern", updateEntry);
Deleting a Crawler Access Rule
Delete a crawler access rule as follows:
myService.DeleteEntry("crawlAccessNTLM", "urlPattern");
Host Load Schedule
Retrieve and update host load schedule information from the search appliance using the hostLoad entry of the config feed.
The default web server host load, a float value. This value measures the relative load on the search appliance based on the number of connections that a search appliance can handle. You can set the defaultHostLoad to a decimal value starting at 0, where 0 indicates to not crawl the content from the number of URL patterns that you specify. Any decimal value of 1 or more sets the average number of connections per minute. A decimal value under 1 sets the percentage of time during which the search appliance opens connections. For more information, see the online help for Content Sources > Web Crawl > Host Load Schedule. |
|||||||
hostName startTime endTime loadFactor
|
|||||||
Retrieving the Host Load Schedule
Retrieve information about the host load schedule from a search appliance as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("config", "hostLoad");
Console.WriteLine("URL Pattern: " + myEntry.GetGsaContent("defaultHostLoad"));
Console.WriteLine("User Name: " + myEntry.GetGsaContent("exceptionHostLoad"));
Console.WriteLine("Order: " + myEntry.GetGsaContent("maxURLs"));
Updating the Host Load Schedule
Update the host load schedule setting in a search appliance as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property for the Host Load Schedule to updateEntry
updateEntry.AddGsaContent("defaultHostLoad", "2.4");
updateEntry.AddGsaContent("exceptionHostLoad",
"* 3 5 1.2 \n www.example.com 1 6 3.6");
updateEntry.AddGsaContent("maxURLs", "3000");
// Send the request
myService.UpdateEntry("config", "hostLoad", updateEntry);
Freshness Tuning
Increase or decrease the crawling frequency by specifying URL patterns.
Retrieving the Freshness Configuration
Retrieve the freshness tuning configuration as follows:
GsaEntry myEntry = myService.GetEntry("config", "freshness");
Console.WriteLine("Archive URLs: " + myEntry.GetGsaContent("archiveURLs"));
Console.WriteLine("Frequent URLs: " + myEntry.GetGsaContent("frequentURLs"));
Console.WriteLine("Force URLs: " + myEntry.GetGsaContent("forceURLs"));
Updating the Freshness Configuration
Update the settings for freshness tuning as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property for updateEntry
updateEntry.AddGsaContent("archiveURLs", "http://good/");
updateEntry.AddGsaContent("frequentURLs", "http://frequent/");
updateEntry.AddGsaContent("forceURLs", "http://force/");
// Send the request
myService.UpdateEntry("config", "freshness", updateEntry);
Recrawling URL Patterns
Recrawling URL Patterns Example
Recrawl URL patterns as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property to updateEntry
updateEntry.AddGsaContent("recrawlURLs", "http://recrawl/page.html");
// Send the request
myService.UpdateEntry("command", "recrawlNow", updateEntry);
Connector Managers
Add, retrieve, update, and delete a connector manager associated with a search appliance.
The URL of the application server where the connector manager is installed. |
|
The status of the connection between the search appliance and the connector manager that is deployed on an application server. The value can be Connected or Disconnected. The Disconnected value may occur if the application server is down or there are problems on the network. |
Adding a Connector Manager
Add a connector manager to a search appliance as follows:
// Create an entry to hold properties to insert
GsaEntry insertEntry = new GsaEntry();
// Add property for insertEntry
insertEntry.AddGsaContent("entryID", "ConnectorManagerOne");
insertEntry.AddGsaContent("description", "Connector Manager One Description");
insertEntry.AddGsaContent("url", "http://example.com:port/");
// Send the request
myService.InsertEntry("connectorManager", insertEntry);
Retrieving a List of Connector Managers
Retrieve a list of connector managers as follows:
// Send the request and print the response
GsaFeed myFeed = myService.GetFeed("connectorManager");
foreach(GsaEntry myEntry in myFeed.Entries) {
Console.WriteLine("Status: " + myEntry.GetGsaContent("status"));
Console.WriteLine("Description: " + myEntry.GetGsaContent("description"));
Console.WriteLine("URL: " + myEntry.GetGsaContent("url"));
}
Retrieve an individual connector manager as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("connectorManager", "ConnectorManagerOne");
Console.WriteLine("Status: " + myEntry.GetGsaContent("status"));
Console.WriteLine("Description: " + myEntry.GetGsaContent("description"));
Console.WriteLine("URL: " + myEntry.GetGsaContent("url"));
Updating a Connector Manager
Update the description and URL for a connector manager as follows:
// Create an entry to hold the properties to update
GsaEntry updateEntry = new GsaEntry();
// Add properties to updateEntry
updateEntry.AddGsaContent("description", "new description");
updateEntry.AddGsaContent("url", "#new URL");
// Send the request
myService.UpdateEntry("connectorManager", "ConnectorManagerOne", updateEntry);
Deleting a Connector Manager
Delete a connector manager as follows:
myService.DeleteEntry("connectorManager", "ConnectorManagerOne");
OneBox Modules Settings
Retrieve and update OneBox module settings for the search appliance using the config feed.
Retrieving OneBox Module Settings
Retrieve OneBox information for a search appliance as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("config", "oneboxSetting");
Console.WriteLine("Max Results: " + myEntry.GetGsaContent("maxResults"));
Console.WriteLine("Timeout: " + myEntry.GetGsaContent("timeout"));
The properties for retrieving a OneBox are as follows:
Updating OneBox Module Settings
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add properties for the OneBox settings to updateEntry
updateEntry.AddGsaContent("maxResults", "3");
updateEntry.AddGsaContent("timeout", "2000");
// Send the request
myService.UpdateEntry("config", "oneboxSetting", updateEntry);
OneBox Modules Retrieve and Delete
Retrieve and delete OneBox modules from the search appliance using the onebox feed.
Retrieving OneBox Module Information
Retrieve information about all the OneBox modules from a search appliance using the onebox feed:
// Send the request and print the response
GsaFeed myFeed = myService.GetFeed("onebox");
foreach(GsaEntry myEntry in myFeed.Entries) {
// Get information on each myEntry
Console.WriteLine("OneBox Name: " + myEntry.GetGsaContent("entryID"));
}
Note: Because detailed information about the OneBox configuration not supported by this API, the onebox feed provides only OneBox module names.
Retrieve an individual OneBox module’s log information from a search appliance as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("onebox",ONEBOX_NAME);
Console.WriteLine("OneBox Log: " + myEntry.GetGsaContent("logContent"));
Note: You can only retrieve OneBox log entries individually.
Deleting a OneBox Module
Delete a OneBox module from a search appliance as follows:
myService.DeleteEntry("onebox", ONEBOX_NAME);
Pause or Resume Crawl
Check crawl status, pause the crawl, or resume the crawl.
Indicates: 1 if crawl is paused, 0 if crawling is occurring. |
Retrieving Crawl Status
Retrieve the status of crawl as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("command", "pauseCrawl");
Console.WriteLine("Pause Crawl: " + myEntry.GetGsaContent("pauseCrawl"));
Pausing or Resuming Crawl
Pause or resume a crawl as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add properties to updateEntry
updateEntry.AddGsaContent("pauseCrawl", "0");
updateEntry.AddGsaContent("doNotCrawlURLs", "http://frequent/");
// Send the request
myService.UpdateEntry("command", "pauseCrawl", updateEntry);
Document Status
Retrieve document status using the properties that follow.
Retrieving Document Status
Retrieve the document status as follows:
GsaEntry myEntry = myService.GetEntry("status", "documentStatus");
Console.WriteLine("Served URLs: " + myEntry.GetGsaContent("servedURLs"));
Console.WriteLine("Crawled Pages Per Second: " + myEntry.GetGsaContent
("crawlPagePerSecond"));
Console.WriteLine("Crawled URLs Today: " + myEntry.GetGsaContent
("crawledURLsToday"));
Console.WriteLine("Found URLs: " + myEntry.GetGsaContent("foundURLs"));
Console.WriteLine("Filtered Bytes: " + myEntry.GetGsaContent("filteredBytes"));
Console.WriteLine("Error URLs Today: " + myEntry.GetGsaContent
("errorURLsToday"));
Index
The sections that follow describe how to configure the Index features of the Admin Console:
Collections
Retrieve, update, create, or delete the collections of documents on the search appliance.
Creating a Collection
Create a new collection as follows:
// Create an entry to hold properties to insert
GsaEntry insertEntry = new GsaEntry();
// Add a property to insertEntry
insertEntry.AddGsaContent("collectionName", "new_collection");
insertEntry.AddGsaContent("insertMethod", "default");
// Send the request
myService.InsertEntry("collection", insertEntry);
Create a new collection with a default setting as follows:
insertEntry.AddGsaContent("insertMethod", "default");
Specify the settings for a new collection as follows:
// Add property for insertEntry
insertEntry.AddGsaContent("collectionName", "new_collection");
insertEntry.AddGsaContent("insertMethod", "customize");
insertEntry.AddGsaContent("followURLs", "#url to follow");
insertEntry.AddGsaContent("doNotCrawlURLs", "#url to not follow");
Retrieving All Collections
Retrieve a list of collections as follows:
// Send the request and print the response
GsaFeed myFeed = myService.GetFeed("collection");
foreach(GsaEntry myEntry in myFeed.Entries) {
Console.WriteLine("Collection Name: " + myEntry.GetGsaContent("entryID"));
Console.WriteLine("Follow URLs: " + myEntry.GetGsaContent("followURLs"));
Console.WriteLine("Do Not Crawl URLs: " + myEntry.GetGsaContent
("doNotCrawlURLs"));
}
Retrieving a Collection
Retrieve the attributes of a single collection as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("frontend", "default_collection");
Console.WriteLine("Follow URLs: " + myEntry.GetGsaContent("followURLs"));
Console.WriteLine("Do Not Crawl URLs: " + myEntry.GetGsaContent
("doNotCrawlURLs"));
Updating a Collection
Update the attributes of a collection as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add properties to updateEntry
updateEntry.AddGsaContent("followURLs", "http://good/");
updateEntry.AddGsaContent("doNotCrawlURLs", "http://frequent/");
// Send the request
myService.UpdateEntry("collection", "default_collection", updateEntry);
Deleting a Collection
Delete a collection as follows:
myService.DeleteEntry("collection", "new_collection");
Index Diagnostics
List crawled documents and retrieve the status of documents in a search appliance using the diagnostics feed.
Document Status Values
The following tables list the document status values.
Note: Use the all to indicate any status value.
robots.txt forbidden |
Listing Documents
Name of a collection that you want to list. The default value is the last used collection. |
|||||||||||||
Indicates: false: (Default) List the files and directories specified by the URL. true: List all files specified by a URL as a flat list. |
|||||||||||||
Indicates: false: (Default) Return documents with a status equal to view. true: Return documents with a status equal to view. |
|||||||||||||
The key field on which to sort:
|
|||||||||||||
The prefix of URL of a document that you want to list. If not blank, it must contain at least http://hostname.domain.com/. The default value is "". |
|||||||||||||
The filter of document status. The values of view are described in Document Status Values. The default value is all. |
List documents by sending an authenticated GET request to the root entry of the diagnostics feed.
A description entry, a set of document status entries and a set of directory status entries are returned.
Directory status entry properties:
DirectoryContentData or HostContentData. |
Document status entry properties:
The status of this document. See Document Status Values for possible docState values. |
|
Dictionary<string, string> queries = new Dictionary<string, string>();
queries.Add("uriAt","http://server.com/secured/test1/");
GsaFeed myFeed = myService.QueryFeed("diagnostics", queries);
foreach(GsaEntry entry in myFeed.Entries) {
Console.WriteLine(entry.GetGsaContent("entryID"));
if (entry.GetGsaContent("entryID").Equals("description")) {
Console.WriteLine("Number of Pages: " + entry.GetGsaContent("numPages"));
Console.WriteLine("URI At: " + entry.GetGsaContent("uriAt"));
} else if (entry.GetGsaContent("type").Equals("DirectoryContentData" )||
entry.GetGsaContent("type").Equals("HostContentData")) {
Console.WriteLine("Type: " + entry.GetGsaContent("type"));
Console.WriteLine("Number of Crawled URLs: " +
entry.GetGsaContent("numCrawledURLs"));
Console.WriteLine("Number of Retrieval Errors: " +
entry.GetGsaContent("numRetrievalErrors"));
Console.WriteLine("Number of Excluded URLs: " +
entry.GetGsaContent("numExcludedURLs"));
} else if (entry.GetGsaContent("type").Equals("FileContentData")) {
Console.WriteLine("Type: " + entry.GetGsaContent("type"));
Console.WriteLine("Time Stamp: " + entry.GetGsaContent("timeStamp"));
Console.WriteLine("Document State: " + entry.GetGsaContent("docState"));
Console.WriteLine("Is Cookie Server Error: " +
entry.GetGsaContent("isCookieServerError"));
}
}
Viewing Index Diagnostics for a Document
Retrieve detailed information about a document by sending an authenticated GET request to a document status entry of the diagnostics feed. The parameter is as follows.
Name of the collection for which you want to view crawl diagnostics. |
A detailed document status entry is returned.
Detailed document status entry properties:
GsaEntry entry = myService.GetEntry("diagnostics",
"http://server.com/secured/test1/doc_0_2.html");
Console.WriteLine("Collection List: " + entry.GetGsaContent("collectionList"));
Console.WriteLine("Forward Links: " + entry.GetGsaContent("forwardLinks"));
Console.WriteLine("Backward Links: " + entry.GetGsaContent("backwardLinks"));
Console.WriteLine("Is Cached: " + entry.GetGsaContent("isCached"));
Console.WriteLine("Document Date: " + entry.GetGsaContent("date"));
Console.WriteLine("Last Modified Date: " + entry.GetGsaContent
("lastModifiedDate"));
Console.WriteLine("Latest Serving Version Timestamp: " +
entry.getGsaContent("latestOnDisk"));
Console.WriteLine("Currently In Process: " + entry.getGsaContent
("currentlyInflight"));
Console.WriteLine("Content Size: " + entry.getGsaContent("contentSize"));
Console.WriteLine("Content Type: " + entry.getGsaContent("contentType"));
Console.WriteLine("Crawl Frequency: " + entry.getGsaContent("crawlFrequency"));
Console.WriteLine("Crawl History: " + entry.getGsaContent("crawlHistory"));
Content Statistics
Retrieve content statistics for each kind of document using the contentStatistics feed.
Common query parameters for all requests:
Name of the collection for which you want to view content statistics. |
Content statistics entry properties:
The MIME type of the documents, such as, plain/text. |
|
The maximum document size for the crawled files with this MIME type. |
|
The minimum document size for the crawled files with this MIME type. |
|
Retrieving Content Statistics For All Crawled Files
Retrieve content statistics for all crawled files in a search appliance by sending an authenticated GET request to the root entry of the contentStatistics feed.
A list of content statistics entries are returned.
GsaFeed myFeed = myService.GetFeed("contentStatistics");
foreach(GsaEntry entry in myFeed.Entries) {
Console.WriteLine("Entry Name: " + entry.GetGsaContent("entryID"));
Console.WriteLine("Maximum Size: " + entry.GetGsaContent("maxSize"));
Console.WriteLine("Minimum Size: " + entry.GetGsaContent("minSize"));
Console.WriteLine("Total Size: " + entry.GetGsaContent("totalSize"));
Console.WriteLine("Average Size: " + entry.GetGsaContent("avgSize"));
Console.WriteLine("Number of Files: " + entry.GetGsaContent("numFiles"));
}
Retrieving Content Statistics For a Crawled File
Retrieve content statistics for a single crawled file by sending an authenticated GET request to a content statistics entry of the contentStatistics feed.
The following content statistics for a crawled file are returned:
GsaEntry entry = myService.GetEntry("contentStatistics", "text/html");
Console.WriteLine("Maximum Size: " + entry.GetGsaContent("maxSize"));
Console.WriteLine("Minimum Size: " + entry.GetGsaContent("minSize"));
Console.WriteLine("Total Size: " + entry.GetGsaContent("totalSize"));
Console.WriteLine("Average Size: " + entry.GetGsaContent("avgSize"));
Console.WriteLine("Number of Files: " + entry.GetGsaContent("numFiles"));
Reset Index
Reset the index for a search appliance using the following properties.
Status message: ERROR, PROGRESS, READY. |
Retrieving Status of a Reset Index
Retrieve the status of a reset index as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("command", "resetIndex");
Console.WriteLine("Reset Index: " + myEntry.GetGsaContent("resetIndex"));
Console.WriteLine("Reset Status Code: " + myEntry.GetGsaContent
("resetStatusCode"));
Console.WriteLine("Reset Status Message: " + myEntry.GetGsaContent
("resetStatusMessage"));
Resetting the Index
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property to updateEntry
updateEntry.AddGsaContent("resetIndex", "1");
myService.UpdateEntry("command", "resetIndex", updateEntry);
Search
The sections that follow describe how to configure the Search features of the Admin Console:
Front Ends: Remove URLs and a Relative OneBox
Retrieve, update, insert, or delete front ends to remove URLs or a relative OneBox for the search appliance using the frontend feed. Retrieve a front end using the following properties.
Retrieving Front Ends, Remove URLs, and a Relative OneBox
Retrieve all the front end information for a search appliance as follows:
// Send a request and print the response
GsaFeed myFeed = myService.GetFeed("frontend");
foreach(GsaEntry myEntry in myFeed.Entries) {
//get information for each myEntry
}
Get information about a front end as follows:
// Send a request and print the response
GsaEntry myEntry = myService.GetEntry("frontend", FRONTEND_NAME);
Console.WriteLine("Front End OneBox: " + myEntry.GetGsaContent
("frontendOnebox"));
Console.WriteLine("Remove URLs: " + myEntry.GetGsaContent("removeUrls"));
Updating Remove URLs and a Relative OneBox
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add properties to updateEntry
updateEntry.AddGsaContent("frontendOnebox", "oneboxtwo");
updateEntry.AddGsaContent("removeUrls", "http://www.example.com/");
// Send the request
myService.UpdateEntry("frontend", FRONTEND_NAME, updateEntry);
Inserting Front Ends and Remove URLs
Insert a front end and remove a URL from the search results as follows:
// Create an entry to hold properties to insert
GsaEntry insertEntry = new GsaEntry();
// Add properties to insertEntry
insertEntry.AddGsaContent("entryID", FRONTEND_NAME);
insertEntry.AddGsaContent("removeUrls", "http://www.example3.com/");
// Send the request
myService.InsertEntry("frontend", insertEntry);
Deleting a Front End
Delete a front end from the search appliance as follows:
myService.DeleteEntry("frontend", FRONTEND_NAME);
Output Format XSLT Stylesheet
Retrieve and update the XSLT template and other output format-related properties for each language of each front end using the frontend entry of the outputFormat feed.
Specify a language for the output format properties that you want to retrieve. Each front end can contain multiple languages, and each language has its own output format properties. Each front end + language can have its own XSLT stylesheet. The language parameter enables you to retrieve and update a stylesheet for a front end associated with a language. Administrators who use the Admin Console set the language in their browser and the Admin Console then displays in that language (if the Admin Console has been translated into that language). Hence the language parameter for the outputFormat feed is limited to the values to which the Admin Console is translated. |
Use the following properties to access the XSLT template information.
Set to 1 if the designated language is the default language for the specified front end, set to 0 if not. |
|
Set to 0 if the style sheet is the default stylesheet that has not been previously edited. Set to 1 if the style sheet has been edited. |
|
When retrieving, the language is determined by the language that is specified by the query parameter. When updating, the language is passed as an entry property to specify the language of the output stylesheet. |
|
Set to 1 to restore custom-edited XSLT code back to the default values. A 0 value has no effect. |
|
Note: For the update action, the restoreDefaultFormat content is mutually exclusive from the styleSheetContent. For each update action, you should either restore the output format XSLT stylesheet back to the original default values, set the XSLT stylesheet to a custom format, or neither, but not both.
Retrieving the Output Format XSLT Stylesheet
Retrieve the output format stylesheet information from a search appliance as follows:
Dictionary<string, string> queryMap = new Dictionary<string, string>();
// Initialize the query map
queryMap.Add("language", "en");
GsaEntry myEntry = myService.QueryEntry("outputFormat", "default_frontend", queryMap);
Console.WriteLine("Language: " + myEntry.GetGsaContent("language"));
Console.WriteLine("Default Language: " + myEntry.GetGsaContent
("isDefaultLanguage"));
Console.WriteLine("Is the Style Sheet Edited: " + myEntry.GetGsaContent
("isStyleSheetEdited"));
Console.WriteLine("XSLT Stylesheet Content: " + myEntry.GetGsaContent
("styleSheetContent"));
Updating the Output Format XSLT Stylesheet
Update the output format stylesheet information in a search appliance as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// The language parameter is passed as part of
// the entry because we cannot use a query parameter
updateEntry.AddGsaContent("language", "en");
// Indicate that the XSLT stylesheet has default values
updateEntry.AddGsaContent("isDefaultLanguage, "1");
// Add this line to update the style sheet content
updateEntry.AddGsaContent("styleSheetContent", "{my new style sheet XSLT}");
// Or add this line to restore the stylesheet content to
// the default, which is mutually exclusive from the previous line
updateEntry.AddGsaContent("restoreDefaultFormat", "1");
// Send the request and print the response
myService.UpdateEntry("outputFormat", "default_frontend", updateEntry);
Console.WriteLine("Output Format: " + updateEntry.GetGsaContent("outputFormat"));
Console.WriteLine("Default Front End: " + updateEntry.GetGsaContent
("default_frontend"));
KeyMatch Settings
A query string to perform a full text search. For example, if you set computer in the query parameter, then you get all KeyMatch settings that contain the word computer. |
|
The number of result lines in a response, default value is 50 lines. |
Use the following properties to set KeyMatch configurations.
The line_number of the KeyMatch configuration rule. |
|||||||
The starting line number of a KeyMatch configuration to change. The minimum value is 0. |
|||||||
The method to change a KeyMatch configuration.
|
Note: The format for a KeyMatch configuration rule is as follows:
Search_Term,KeyMatch_Type,URL,Title
KeyMatch_Type can be: KeywordMatch, PhraseMatch, or ExactMatch.
Search_Term and URL fields cannot be empty. The KeyMatch configuration conforms to the CSV format, which uses commas to separate values.
Retrieving KeyMatch Settings
Retrieve KeyMatch settings as follows:
Dictionary<string, string> queryMap = new Dictionary<string, string>();
// 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<string, string> 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);
The following example updates KeyMatch settings:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
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
myService.UpdateEntry("keymatch", "myFrontend", updateEntry);
Note: Delete a setting by changing the statement to three commas (,,,).
The following example replaces KeyMatch settings:
// Create an entry to hold properties to replace
GsaEntry replaceEntry = new GsaEntry();
replaceEntry.AddGsaContent("updateMethod", "replace");
// 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";
replaceEntry.AddGsaContent("newLines", newLines);
// Send the request to the search appliance
myService.UpdateEntry("keymatch", "myFrontend", replaceEntry);
Related Queries
The starting line number of the result, the default value is to start at line 0. |
|
The number of result lines in the response, the default value is 50 lines. |
Use the following properties to access related queries.
The line number of the related query configuration rule (in all the rules). |
|||||||
The starting line number of the related query configuration to change. The minimum value is 0. |
|||||||
The method to use to change related query configurations.
|
Note: A related query configuration rule is in the following format:
Search_Terms,Related_Queries
The Search_Terms and the Related_Queries values cannot be empty. The related query configuration rules conform to the CSV format, which uses commas to separate values.
Retrieving Related Queries
Retrieve related queries as follows:
Dictionary<string, string> queryMap = new Dictionary<string, string>();
// 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("synonym", "myFrontend", queryMap);
foreach(KeyValuePair<string, string> kvp in myEntry.GetAllGsaContents()) {
if (Regex.IsMatch(kvp.Key, @"^\d+$")) {
Console.WriteLine("The line " + kvp.Key + " is: " + kvp.Value);
}
}
Changing Related Queries
The following example appends related queries:
// Create an entry to hold properties to append
GsaEntry appendEntry = new GsaEntry();
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
myService.UpdateEntry("synonym", "myFrontend", appendEntry);
The following example updates related queries:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
updateEntry.AddGsaContent("updateMethod", "update");
// Set the starting line number
updateEntry.AddGsaContent("startLine", 0);
// Provide the original content
string originalLines = "airplane,aircraft\ngoogle,googol";
updateEntry.AddGsaContent("originalLines", originalLines);
// Prepare new content
string newLines = "airplane,helicopter\n,";
updateEntry.AddGsaContent("newLines", newLines);
// Send the request to the search appliance
myService.UpdateEntry("synonym", "myFrontend", updateEntry);
Note: Delete a setting by changing the statement to a comma (,) value.
The following example replaces related queries:
// Create an entry to hold properties to replace
GsaEntry replaceEntry = new GsaEntry();
replaceEntry.AddGsaContent("updateMethod", "replace");
// Prepare new content
string newLines = "airplane,aircraft\n" + "google,googol\n" + "stock,security";
replaceEntry.AddGsaContent("newLines", newLines);
// Send the request to the search appliance
myService.UpdateEntry("synonym", "myFrontend", replaceEntry);
Query Suggestion
There are two features for working with query suggestions:
Query Suggestion Blacklist
The query suggestion blacklist supports the /suggest feature described in the Query Suggestion Service /suggest Protocol chapter of the Search Protocol Reference. This feature uses the suggest feed to retrieve and update the query suggestion blacklist entries.
The query suggestion blacklist supports the regular expressions in the re2 library (http://code.google.com/p/re2/wiki/Syntax). If you want specify an exact match, you need to use the following syntax:
^the_word_to_match$
Retrieving Query Suggestion Blacklist Information
Retrieve query suggestion blacklist information as follows:
// Create a GsaClient
GsaClient client = new GsaClient("SearchAppliance", 8000, "username",
"password");
// Get and print the current content of the blacklist file
GsaEntry entry = client.GetEntry("suggest", "suggestBlacklist");
Console.WriteLine("Current content: " + entry.GetGsaContent("suggestBlacklist"));
Updating Query Suggestion Blacklist Entries
Update query suggestion blacklist entries as follows:
// Update the content
entry = new GsaEntry();
entry.AddGsaContent ("suggestBlacklist",
"bad_word_3\n^bad_word_1$\ncar[0-9]{4}.*\n");
client.UpdateEntry("suggest", "suggestBlacklist", entry);
Query Suggestion Refresh
The query suggestion refresh supports the /suggest feature described in the Query Suggestion Service /suggest Protocol chapter of the Search Protocol Reference. This feature uses the suggest feed to refresh the query suggestion database.
Refresh query suggestions as follows:
GsaClient client = new GsaClient("SearchAppliance", 8000, "username",
"password");
entry = new GsaEntry();
entry.AddGsaContent ("suggestRefresh", "1");
client.UpdateEntry("suggest", "suggestRefresh", entry);
Search Status
Retrieve the search status for the search appliance using the servingStatus entry of the status feed.
Average queries per minute served recently on the search appliance. |
|
Retrieving Search Status
Retrieve the current search appliance serving status as follows:
GsaEntry myEntry = myService.GetEntry("status", "servingStatus");
Console.WriteLine("Queries Per Minute: " + myEntry.GetGsaContent
("queriesPerMinute"));
Reports
The sections that follow describe how to configure the Reports features of the Admin Console:
Search Reports
Generate, update, and delete search reports using the searchReport feed.
Search report entry properties:
(Write only) The collection name—only use to create a search report. |
|||||||||||
Search_Report_Name@Collection_Name |
|||||||||||
The dates of each query that is collected in the search report. |
|||||||||||
(Write only) The report name—only use to create a search report. |
|||||||||||
(Read only) The status of a search report:
|
|||||||||||
Indicates if a query should only count searches that have results. The default value is false. |
Listing a Search Report
List search report entries by sending an authenticated GET request to the root entry of the searchReport feed. Query parameter:
Collection Name of search report. The default value is all.collections. |
A list of search report entries returns:
GsaFeed myFeed = myService.GetFeed("searchReport");
foreach(GsaEntry entry in myFeed.Entries) {
Console.WriteLine("Entry Name: " + entry.GetGsaContent("entryID"));
Console.WriteLine("Report State: " + entry.GetGsaContent("reportState"));
Console.WriteLine("Report Creation Date: " +
entry.GetGsaContent("reportCreationDate"));
Console.WriteLine("Report Date: " + entry.GetGsaContent("reportDate"));
Console.WriteLine("Is Final: " + entry.GetGsaContent("isFinal"));
Console.WriteLine("With Results: " + entry.GetGsaContent("withResults"));
Console.WriteLine("Top Count: " + entry.GetGsaContent("topCount"));
Console.WriteLine("Diagnostic Terms: " +
entry.GetGsaContent("diagnosticTerms"));
}
Creating a Search Report
Create a new search report entry by sending an authenticated POST request to the root entry of the searchReport feed.
The possible date formats for reports are as follows.
date_month_day_year |
|
month_month_year |
|
year_year |
|
range_month_day_year_month_day_year |
insertEntry.addGsaContent(“reportDate”, “range_1_2_2009_9_23_2009);
A new search report entry will be generated and returned as follows.
GsaEntry insertEntry = new GsaEntry();
insertEntry.AddGsaContent("reportName", "bbb");
insertEntry.AddGsaContent("collectionName", "default_collection");
insertEntry.AddGsaContent("reportDate", "month_5_2009");
insertEntry.AddGsaContent("withResults", "true");
insertEntry.AddGsaContent("topCount", "100");
myService.InsertEntry("searchReport", insertEntry);
Retrieving a Search Report
Retrieve the search report status and get search log content by sending an authenticated GET request to a search report entry of the searchReport feed.
A search report entry with log content (if content is ready) is returned:
GsaEntry entry = myService.GetEntry("searchReport", "bbb@default_collection");
Console.WriteLine("Entry Name: " + entry.GetGsaContent("entryID"));
Console.WriteLine("Report State: " + entry.GetGsaContent("reportState"));
Console.WriteLine("Report Creation Date: " +
entry.GetGsaContent("reportCreationDate"));
Console.WriteLine("Report Date: " + entry.GetGsaContent("reportDate"));
Console.WriteLine("Is Final: " + entry.GetGsaContent("isFinal"));
Console.WriteLine("With Results: " + entry.GetGsaContent("withResults"));
Console.WriteLine("Top Count: " + entry.GetGsaContent("topCount"));
Console.WriteLine("Diagnostic Terms: " + entry.GetGsaContent("diagnosticTerms"));
string status = entry.GetGsaContent("reportState");
if (status.Equals("2") || status.Equals("3")) {
Console.WriteLine("Report Content: " + entry.GetGsaContent("reportContent"));
}
Updating a Search Report
Update the search report status and get search report content by sending an authenticated PUT request to a search report entry of the searchReport feed. There are no properties.
A search log entry is returned:
GsaEntry updateEntry = new GsaEntry();
myService.UpdateEntry("searchReport", "bbb@default_collection");
Deleting a Search Report
Delete a search report by sending an authenticated DELETE request to a search report entry of the searchReport feed.
The search report entry will be deleted:
myService.DeleteEntry("searchReport", "bbb@default_collection");
Search Logs
Generate, update, and delete a search log using the searchLog feed. A search log lists all search queries for a specified time frame in a format similar to a common log format (CLF).
(Write-only) The collection name—use only to create a search log. |
|||||||||||
Search_Log_Name@Collection_Name |
|||||||||||
(Write-only) The report name—use only to create a search log. |
|||||||||||
(Read only) Search log status:
|
|||||||||||
Listing a Search Log
List search log entries by sending an authenticated GET request to the root entry of the searchLog feed.
Collection name of a search log. The default value is all.collections. |
A list of search log entries will be returned.
GsaFeed myFeed = myService.GetFeed("searchLog");
foreach(GsaEntry entry in myFeed.Entries) {
Console.WriteLine("Entry Name: " + entry.GetGsaContent("entryID"));
Console.WriteLine("Report State: " + entry.GetGsaContent("reportState"));
Console.WriteLine("Report Creation Date: " +
entry.GetGsaContent("reportCreationDate"));
Console.WriteLine("Report Date: " + entry.GetGsaContent("reportDate"));
Console.WriteLine("Is Final: " + entry.GetGsaContent("isFinal"));
}
Creating a Search Log
Create a new search log entry by sending an authenticated POST request to the root entry of the searchLog feed.
A new search log entry will be generated and returned.
GsaEntry insertEntry = new GsaEntry();
insertEntry.AddGsaContent("reportName", "bbb");
insertEntry.AddGsaContent("collectionName", "default_collection");
insertEntry.AddGsaContent("reportDate", "date_3_25_2009");
myService.InsertEntry("searchLog", insertEntry);
Retrieving a Search Log
Check the search log status and get search log content by sending an authenticated GET request to the search log entry of the searchLog feed using the following query parameters.
Query string for the logContent. The logContent contains many lines of logs. The query string applies to each line, and only lines that contain the query string are returned. |
|
The maximum logContent lines to retrieve. The default value is 50 lines. |
|
The first logContent lines to retrieve. The default value is 1 line. |
A search log entry with logContent, if content is ready, is returned.
Dictionary<string, string> queries = new Dictionary<string, string>();
queries.Add("query","User");
queries.Add("startLine","1");
queries.Add("maxLine","10");
GsaEntry entry = myService.QueryEntry("searchLog", "bbb@default_collection",
queries);
Console.WriteLine("Entry Name: " + entry.GetGsaContent("entryID"));
Console.WriteLine("Report State: " + entry.GetGsaContent("reportState"));
Console.WriteLine("Report Creation Date: " + entry.GetGsaContent("reportCreationDate"));
Console.WriteLine("Report Date: " + entry.GetGsaContent("reportDate"));
Console.WriteLine("Is Final: " + entry.GetGsaContent("isFinal"));
string status = entry.GetGsaContent("reportState");
if (status.Equals("2") || status.Equals("3")) {
Console.WriteLine("Log Content: " + entry.GetGsaContent("logContent"));
Console.WriteLine("To Line: " + entry.GetGsaContent("toLine"));
Console.WriteLine("From Line: " + entry.GetGsaContent("fromLine"));
Console.WriteLine("Total Lines: " + entry.GetGsaContent("totalLines"));
}
Updating a Search Log
Update the search log status and get search log content by sending an authenticated PUT request to the search log entry of the searchLog feed. No properties are required.
GsaEntry updateEntry = new GsaEntry();
myService.UpdateEntry("searchLog","bbb@default_collection");
Deleting a Search Log
Update the search log status and get search log content by sending an authenticated DELETE request to a search log entry of the searchLog feed.
The search log entry will be deleted.
myService.DeleteEntry("searchLog", "bbb@default_collection");
GSA Unification
GSA Unification is also known as dynamic scalability. This section describes use of the federation feed.
Configuring a GSA Unification Network
The ID of the search appliance, required to identify the node during node operations. |
|||||||
The type of search appliance. Possible values:
|
|||||||
Adding a GSA Unification Node
Add a GSA Unification node as follows:
// Create an entry to hold properties to insert
GsaEntry insertEntry = new GsaEntry();
// In the following example code, add a secondary
// node with arbitrary values for the various settings.
// Add properties to insertEntry
insertEntry.AddGsaContent("entryID", "node_appliance_id");
insertEntry.AddGsaContent("nodeType", "SECONDARY");
insertEntry.AddGsaContent("federationNetworkIP", "10.0.0.2");
insertEntry.AddGsaContent("secretToken", "token");
insertEntry.AddGsaContent("hostname", "corp.domain.x.com");
insertEntry.AddGsaContent("scoringBias", "20");
// Send the request
myService.InsertEntry("federation", insertEntry);
Retrieving a Node Configuration
Retrieve the configuration information about a GSA Unification node as follows:
// Send a request and print the response
GsaEntry myEntry = myService.GetEntry("federation", "applianceId");
string type = myEntry.GetGsaContent("nodeType");
Console.WriteLine("Node Type: " + type);
Console.WriteLine("GSA Unification Network IP: " + myEntry.GetGsaContent
("federationNetworkIP"));
Console.WriteLine("Host Name: " + myEntry.GetGsaContent("hostname"));
Console.WriteLine("Secret Token: " + myEntry.GetGsaContent("secretToken"));
Console.WriteLine("Scoring Bias: " + myEntry.GetGsaContent("scoringBias"));
if (type.Equals("SECONDARY")) {
Console.WriteLine("Remote Front End: " + myEntry.GetGsaContent
("remoteFrontend"));
Console.WriteLine("Node Timeout: " + myEntry.GetGsaContent("slaveTimeout"));
}
if (type.Equals("PRIMARY") || type.Equals("PRIMARY_AND_SECONDARY")) {
Console.WriteLine("Secondary Nodes: " + myEntry.GetGsaContent
("secondaryNodes"));
}
Retrieving All Node Configurations
Retrieve information on all GSA Unification nodes as follows:
// Send the request and print the response
GsaFeed myFeed = myService.GetFeed("federation");
foreach(GsaEntry gsaEntry in myFeed.Entries) {
// Process each entry
}
Updating a Node Configuration
Update the configuration of a node as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add properties to updateEntry
updateEntry.AddGsaContent("entryID", "applianceId");
updateEntry.AddGsaContent("nodeType", "PRIMARY");
updateEntry.AddGsaContent("federationNetworkIP", "10.0.0.3");
updateEntry.AddGsaContent("secretToken", "new_secret_token");
updateEntry.AddGsaContent("hostname", "new_hostname");
updateEntry.AddGsaContent("scoringBias", "20");
// Send the request
myService.UpdateEntry("federation", "applianceId", updateEntry);
Deleting a Node
myService.DeleteEntry("federation", "applianceId");
Administration
The sections that follow describe how to configure the Administration features of the Admin Console:
License Information
Retrieve license Information from the search appliance using the licenseInfo entry of the info feed.
Note: You can only license information, but not update or install a new license through this API.
Retrieving License Information
Retrieve license information using the following properties.
Identifies when the search appliance software license expires. |
|
Indicates the maximum number of collections. You can configure collections at the ndex > Collections page. |
|
Indicates the maximum number of front ends. You can configure front ends at the Search > Search Features > Front Ends page. |
|
Retrieving License Information Example
Retrieve the license Information from a search appliance as follows:
// Send the request and print the response
GsaEntry myEntry = myService.GetEntry("info", "licenseInfo");
Console.WriteLine("Appliance ID: " + myEntry.GetGsaContent("applianceID"));
Console.WriteLine("License ID: " + myEntry.GetGsaContent("licenseID"));
Console.WriteLine("License Valid Until: " + myEntry.GetGsaContent
("licenseValidUntil"));
Console.WriteLine("Maximum Front Ends: " + myEntry.GetGsaContent
("maxFrontends"));
Console.WriteLine("Maximum Pages: " + myEntry.GetGsaContent("maxPages"));
Console.WriteLine("Maximum Collections: " + myEntry.GetGsaContent
("maxCollections"));
Import and Export
Import or export a search appliance configuration using the importExport entry of the config feed.
The following is the common query parameter for all requests.
Specify importExport entry properties.
Exporting a Configuration
Export a search appliance configuration by sending an authenticated GET request to the importExport entry of the config feed.
The following importExport entry is returned:
Dictionary<string, string> queries = new Dictionary<string, string>();
queries.Add("password", "12345678");
GsaEntry entry = myService.QueryEntry("config", "importExport", queries);
Console.WriteLine("XML Data: " + entry.GetGsaContent("xmlData"));
Importing a Configuration
Import a search appliance configuration sending an authenticated PUT request to the importExport entry of the config feed.
GsaEntry updateEntry = new GsaEntry();
updateEntry.AddGsaContent("xmlData", "<config data>");
updateEntry.AddGsaContent("password", "12345678");
myService.UpdateEntry("config", "importExport", updateEntry);
Event Log
Retrieve lines from the event log for a search appliance by using the eventLog entry of the logs feed. The following parameters let you make a query, specify a starting line, and specify the number of event log statements to retrieve.
Query string for the logContent. The logContent contains many lines of logs. The query string applies to each line, only lines that contain the query string are returned. |
|
The starting line number to retrieve from the event log. The default value is 1. |
|
The maximum number of lines in the event log to retrieve. The default value is 50 lines. |
Use the following properties to retrieve event log lines and event log content.
Retrieving an Event Log
Retrieve the event log information from a search appliance as follows:
Dictionary<string, string> queries = new Dictionary<string, string>();
queries.Add("query","User");
queries.Add("startLine","10");
queries.Add("maxLine","2");
GsaEntry myEntry = myService.QueryEntry("logs", "eventLog", queries);
Console.WriteLine("Log Content: " + myEntry.GetGsaContent("logContent"));
Console.WriteLine("Total Lines: " + myEntry.GetGsaContent("totalLines"));
Console.WriteLine("From Line: " + myEntry.GetGsaContent("fromLine"));
Console.WriteLine("To Line: " + myEntry.GetGsaContent("toLine"));
System Status
System status for the search appliance can be retrieved through the systemStatus entry of the status feed.
Temperature of the CPU. Set to 0 if okay, 1 if caution, 2 if critical. |
|
Remaining disk capacity of a search appliance. Set to 0 if okay, 1 if caution, 2 if critical. |
|
Health of the motherboard. Set to 0 if okay, 1 if caution, 2 if critical. |
|
Overall health of the a search appliance. Set to 0 if okay, 1 if caution, 2 if critical. |
|
Health of the RAID array. Set to 0 if okay, 1 if caution, 2 if critical. |
Note: Some health properties may not exist in certain versions of the search appliance.
Retrieving System Status
Retrieve a the current search appliance system status as follows:
GsaEntry myEntry = myService.GetEntry("status", "systemStatus");
Console.WriteLine("Overall Health: " + myEntry.GetGsaContent("overallHealth"));
Console.WriteLine("Disk Capacity: " + myEntry.GetGsaContent("diskCapacity"));
Console.WriteLine("RAID Health: " + myEntry.GetGsaContent("raidHealth"));
Console.WriteLine("CPU Temperature: " + myEntry.GetGsaContent("cpuTemperature"));
Console.WriteLine("Machine Health: " + myEntry.GetGsaContent("machineHealth"));
Shutdown or Reboot
Shut down or reboot the search appliance.
Command sent to the search appliance. The command can be shutdown or reboot. |
|||||||
Indicates the search appliance status:
|
Shutting Down or Rebooting
Shut down or reboot the search appliance as follows:
// Create an entry to hold properties to update
GsaEntry updateEntry = new GsaEntry();
// Add a property to updateEntry
updateEntry.AddGsaContent("command", "reboot");
myService.UpdateEntry("command", "shutdown", updateEntry);