Sun Java System Portal Server 7.1 Developer's Guide

Chapter 28 Overview of the Search Engine Java SDK

This chapter contains the following sections:

Introduction to Search Engine Java SDK

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:

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 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 Search format, where Search stands for Summary Object Interchange Format.

For a discussion of Search, see:

http://www.w3.org/TR/NOTE-rdm.html#search.

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 applet viewer 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

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


    javac -classpath PortalServer-base/sdk/searchsdk.jar SearchDemo.java
  2. 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
  3. 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 PortalServer-base
    /sdk/searchsdk.jar com.sun.portal.search.demo.SearchDemo http://
    portal_server_host_name:port/search-ID/search ’search query’

ProcedureTo Install and Run the Search Demo Applet

To run the search demo as an applet, use the JDK applet viewer or a browser with the Java 1.3.1 plug-in. You must also edit SearchDemo.html to configure the information about your search engine location.


Note –

The instructions included here are for applet viewer. To run the applet in a browser, you need Java 1.2 or later browser plugin. More information on the Java browser plug-in 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.

    For example, enter:


    javac -classpath PortalServer-base/sdk/searchsdk.jar SearchDemo.java
  2. 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
  3. 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:

  4. 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.

  5. 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