This chapter describes how you can search content on a virtual server. Sun Java System Web Server 6.1 includes a search engine that allows you to search documents on the server and display results on a web page. It provides a default search web application which you can enable or disable on a specific virtual server. This search application provides the basic web pages used to query collections and view results.
Search can be enabled on a virtual server, ensure that Java is enabled for the virtual server class that contains the virtual server. Java is enabled by default and you can enable/disable it per server instance in Sun Java System Web Server 6.1 The Java tab for the virtual server contains a link, the Enable/Disable Java link, that takes you to a page which allows you to enable or disable Java.
Next, because searches require a database of searchable documents (called a collection) against which users can search, you need to create this database. At a minimum, you must have at least one collection configured on your server. You can however create as many collections as required.
This chapter includes the following sections:
Let’s say you want to create a collection called “HR” on your virtual server acme. To do so, use the Create Collection page in the Search tab of your virtual server.
In the figure above, certain examples are specified. These parameters define our collection.
/hr/publish/info is the directory from which documents will be indexed by the collection. By default, only the directory designated as the document root directory for the virtual server is listed for selection. To add a directory to the list of indexable directories, you must create additional document directories, as discussed in Chapter 2, Creating and Using Virtual Servers
“HR Docs” is the display name. This is what end users will see as the name of the collection in the search query page. If this field is left blank, the collection name “HR”, would appear on the search query page.
The Encoding field is left as is. This means that the default encoding, “ISO-8859-1” will be used. If, for instance, the documents you want to index are in Japanese, you might use an appropriate encoding such as, “Shift_JIS.”
You need to save and apply your changes after updating the page for the changes to take effect.
You can update any of the parameters in the search collections you have created at any time using the Update Collection link on the Search tab of the virtual server.
When you add new documents to the /hr/publish/info folder, update the “HR” collection to index the new documents into the collection by manually using the Update Collections page.
If your site is constantly being updated, schedule regular maintenance tasks on the collection. You might for example, wish to update your collections at the end of the day when you know that new documents are likely to have been added.
To automate maintenance tasks on collections, use the Add Scheduled Maintenance link in the Search tab of the virtual server. Choose Update as the type of task you want to automate, and specify other parameters as appropriate, for example, the time of day to perform the task, the day(s) of the week to perform the task, figure as shown below:
Next, we need to enable the search application on the virtual server using the Search Configuration link in the Search tab of the virtual server.
If you plan to use the default search application, click the Enabled checkbox on this page and use the default values for the rest of the parameters.
You may choose to customize the search application to suit your specific needs. You can use the JSP tag libraries included with Sun Java System Web Server 6.1 to do so. Take a look at the default search application located at server_root/bin/https/webapps/search as a sample application that illustrates the use of customizable search tags. The section on Customizing Search Pages in the Sun Java System Web Server 6.1 Administrator’s Guide provides examples of customizing the search page, by having the query form appear on a side bar of the page or search results appear differently.
For a detailed description of the JSP search tags you can use, see the Sun Java System Web Server 6.1 SP10 Programmer’s Guide to Web Applications.