Sun Java logo     Previous      Contents      Index      Next     

Sun logo
Sun Java System Portal Server 6 2004Q2 Developer's Guide 

Chapter 25
Overview of the Search Engine Java SDK

This chapter contains the following sections:


Introduction

To 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:

portal-server-install-root/SUNWps/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 SDK

The 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 Applications

The 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
  1. Compile the SearchDemo.java file. Make sure the class path includes the SDK JAR file, searchsdk.jar. For example, type:
  2. javac -classpath searchsdk.jar SearchDemo.java

  3. 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.
  4. For example, type:

    mkdir -p com/sun/portal/search/demo; cp *.class com/sun/portal/search/demo

  5. Invoke the search demo from the command line and supply the address of the search server and the query string as arguments.
  6. 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.


Note

The instructions included here are for appletviewer. To run the applet in a browser, you need Java 1.2 or later browser plugin. More information on the Java browser plugin can be found at http://java.sun.com/products/plugin and http://java.sun.com/products/plugin/1.3/docs/tags.html.


  1. Compile the SearchDemo.java file. Make sure the class path includes the SDK JAR file, searchsdk.jar.
  2. For example, enter:

    javac -classpath searchsdk.jar SearchDemo.java

  3. 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.
  4. For example, type:

    mkdir -p com/sun/portal/search/demo; cp *.class com/sun/portal/search/demo

  5. Enter the server location information by editing the applet parameters in SearchDemo.html.
  6. 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:

  1. 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.
  2. You can also add the search demo classes to searchsdk.jar to make the applet available in a single download.

  3. The searchsdk.jar file must be named as the archive attribute of the applet tag in SearchDemo.html.
  4. For example, enter:

    jar uf com/sun/portal/search/demo/*.class searchsdk.jar



Previous      Contents      Index      Next     


Copyright 2004 Sun Microsystems, Inc. All rights reserved.