Integrate Google's web API service in Domino applications

Source: Internet
Author: User
Use Google's web API service to apply to Domino Program Added the Google Web search function. This article will show you how to use a simple proxy to implement the search function in the application. Download Code For example, start googling!

In the face of Google's current and ever-expanding index of more than 3 billion web pages, it will become one of the best tools for performing industrial intensity searches on the Internet. In addition to the number of its web pages, the high quality of search results is also attributed to its proprietary searchAlgorithmThis algorithm is based on correlation and popularity. Recent reports show that Google responds to 0.2 billion search requests in 88 different languages every day (2,300 requests per second on average !). According to the searchenginewatch.com survey, Google processes 75% of all web-based queries.

Obviously, many web users are familiar with Google and its search features. Not so well known, you can use Google's web API service, integrate Google's search functions into your Domino application (as described in the next section, you can download this API for free ). This article describes how to add Google search to Domino applications. We will briefly introduce Google APIs and how they work. Then we will study a sample application that integrates the Google search feature with the domino application. At last, we will provide some ideas on how to expand and customize this simple example to end the discussion in this article. (All the examples in this article are included in a domino database. You can download the database from sandbox .)

This document assumes that you are an experienced Notes application developer who is familiar with writing Domino agents. Although advanced Java experience is not necessary to understand our examples, it is strongly recommended that you understand some basic java knowledge.

Google API

To use Google APIs, download the Google Web API developer toolbox (googleapi.zip) from the Google Web API download page, and create a free Google account to obtain a license key. This key allows you to perform a maximum of 1,000 searches per day (you must include this key in the query when sending a search request. This is done by programming, so you do not have to enter this key every time you execute the query ). This developer toolbox comes with documents and examples to give you a basic understanding of how Google's Automated Search works.

After downloading googleapi.zip, decompress it to the C: googleapi directory. Then you can quickly call the web API by typing the following command at the MS-DOS Command Prompt: Java-CP googleapi. jar COM. google. soap. search. googleapidemo <key> Search Lotus Domino> result.html, where <key> is your registration key, "Lotus dominoworkflow is the object you want to search for, and result.html is the name of the file in which you want to write the search result. For example, the following example:

Listing 1. Search Results
...
Start Index = 1
End Index = 10
Estimated total results number = 663000
...

Displays the first 10 results of the estimated 663,000 query results.

However, if you test the same query on the Google Web site, different results may be obtained. For example, the same query on Google for "Lotus Domino" will produce an estimated 596,000 results. (The Google API Support Team confirmed that the web API and Google site use the same search engine and index page, the nuances of search results may be caused by many data centers maintained by Google .)

Quick View of googleapidemo. Java in the googleapi directory:

Listing 2. code snippets from googleapidemo. Java
...
Googlesearch S = new googlesearch ();
...
Googlesearchresult r = S. dosearch ();
...

You can find that the dosearch () method calls Google search after setting the license key and search string attributes.

Before proceeding to the next example, let's take a quick look at several methods in your Google Web API:

Setkey () sets the user license key.
Setquerystring () sets the query string.
Dosearch () calls Google search.
Tostring () returns the formatted representation of Google search results.
Getresultelements () returns an array of result elements.
Getsnippet () returns a code snippet that shows the query in the URL environment where it appears.
Getsummary () returns the ODP summary when the current document is included in the ODP directory.
Gettitle () returns the title of the search result in HTML format.
Geturl () returns the absolute URL of the search result.
In addition, the following methods can further improve your search application:

setstartresult () sets the index of the first result to be returned. For example, if you have 500 results, you may want to start from 100th results.
setmaxresults () sets the maximum number of results to be returned for each query. The maximum value of each query is 10. If you perform a query without many matching items, the actual number of results may be less than the number you requested.
setfilter () enables or disables the related query filter. Similar results are excluded from this filter.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.