Sun Java System Portal Server 7 Developer's Guide

Creating a Search Object

The entry point for submitting searches is the Search class. You need to create a new Search object, then call doQuery() on it to execute the search query.

The first thing you need to do is create a new Search object. The full constructor syntax is:


public Search(
    String scope
    String viewAttributes,
    String viewOrder,
    int firstHit,
    int viewHits,
    String queryLanguage,
    String database,
    String RDMServer,
    String ssoToken,
)

The arguments for the constructor are outlined in the following table:

String scope

The query string or scope, that is, the string being searched for.

String viewAttributes

A comma-delimited list of the SOIF attributes to be retrieved from the database, such as URL, Author, Description. For example, score,url,title,description,classification.

String viewOrder

The order by which to sort the results. This is a comma-delimited list of attributes. Use the minus sign to indicate descending order, and a plus sign to indicate ascending order. For example, -score,+title.

int firstHits

The hit number of the first result to return. A typical value is 1.

int viewHits

Maximum number of results to return. A typical value is 10.

String queryLanguage

The Search Server query language. You should use search for a normal query.

String database

The logical name of a database (or collection) you wish to search. A typical value is null which will search the server’s default database.

String RDMServer

The URL of the search engine servlet. This argument has the form:

http://hostname.domain.com:port/portal-ID/search

For example, if the search server is installed on www.yourcompany.com on port 80, the value would be:

http://www.yourcompany.com:80/portal-ID/search
String ssoToken

An Sun Java System Access Manager software single sign on token used when doing secure searches. There is also a simpler convenience constructor with the following syntax:

public Search(String scope, String RDMServer)

When this constructor is used the following values are used for the unspecified arguments:

viewAttributes: null. Return all attributes.
viewOrder: null. Use the server default sort order - sorted by relevance.
firsthit: 1. Start hits at hit number 1.
viewhits: 10. Return 10 hits only.
query language: search. Search for documents using the normal query language.
database: null. Search the server’s default database.
ssoToken: null. Use anonymous search.