Sun Java System Portal Server 6 2005Q4 Developer's Guide |
Chapter 25
Overview of the Search Engine Java SDKThis chapter contains the following sections:
IntroductionTo submit queries and add entries to the search engine database by using the Java programming language, you need to use the search engine Java Software Development Kit (SDK), which is available at:
PortalServer-base/sdk/search
The Java SDK includes the Java classes needed for interacting with the search engine database and a sample search application which can be run as an applet or as a stand alone program.
The Search Engine Java SDKThe classes in the search engine Java SDK provide a Java interface for interacting with the search server to access the search engine database.
Using the Java SDK, you can build Java programs, applets, and your own interfaces that submit searches to the search engine.
The search engine database contains resource descriptions for the indexed resources, such as documents. Each resource description is described in SOIF format, where SOIF stands for Summary Object Interchange Format.
For a discussion of SOIF, see:
http://www.w3.org/TR/NOTE-rdm.html#soif.
Running the Sample ApplicationsThe search engine Java SDK contains sample Java and HTML files. SearchDemo.java is an example Java program which can be run as an applet or as a stand alone program. To run the applet version, use the JDK appletviewer or a browser with the Java 1.2 plug-in. You must also edit SearchDemo.html to pass the information about your search engine to the SearchDemo applet. The command line version takes the server information as a command line argument
To Install and Run the Search Demo Command Line Program
- Compile the SearchDemo.java file. Make sure the class path includes the SDK JAR file, searchsdk.jar. For example, type:
javac -classpath searchsdk.jar SearchDemo.java
- Create a directory hierarchy that reflects the Java package structure for these classes to use the compiled classes directly, and move the classes into the demo package of this hierarchy.
For example, type:
mkdir -p com/sun/portal/search/demo; cp *.class com/sun/portal/search/demo
- Invoke the search demo from the command line and supply the address of the search server and the query string as arguments.
For example, type:
java -classpath .:searchsdk.jar com.sun.portal.search.demo.SearchDemo http://portal_server_host_name:port/portal/search ’search query’
The codebase parameter indicates the directory containing the main class and the ancillary classes for the applet. You can specify this in the form:
"http://host_name:compass_server_port/java"
To Install and Run the Search Demo Applet
To run the search demo as an applet, use the JDK appletviewer or a browser with the Java 1.3.1 plugin. You must also edit SearchDemo.html to configure the information about your search engine location.
- Compile the SearchDemo.java file. Make sure the class path includes the SDK JAR file, searchsdk.jar.
For example, enter:
javac -classpath searchsdk.jar SearchDemo.java
- Create a directory hierarchy that reflects the Java package structure for these classes to use the compiled classes directly, and move the classes into the demo package of this hierarchy.
For example, type:
mkdir -p com/sun/portal/search/demo; cp *.class com/sun/portal/search/demo
- Enter the server location information by editing the applet parameters in SearchDemo.html.
For example, type:
<param name="RDMServer" value="http://portal_server_host_name:port/portal/search">
Appletviewer can now be run from the command line. It will access the java classes from the current location. For example, enter:
appletviewer SearchDemo.html
Search queries are entered into the search bow that appears and results are sent to stdout of the controlling terminal. If you are running the applet in a browser, the results are displayed in the Java console.
If you have installed the browser Java plugin, then the instructions are similar to those for appletviewer except that you must make the classes available for download to the client browser. To do this:
- Copy SearchDemo.html, searchsdk.jar and the directory hierarchy created above (including the SearchDemo classes) to a location that is in the content path of your web server.
You can also add the search demo classes to searchsdk.jar to make the applet available in a single download.
- The searchsdk.jar file must be named as the archive attribute of the applet tag in SearchDemo.html.
For example, enter:
jar uf com/sun/portal/search/demo/*.class searchsdk.jar