Quickstart: Customizing
search
|
This is a short tutorial for server administrators who need to customize
the Netscape search interface to better accomodate their user community.
The search interface consists of four types of pages and this tutorial
provides information about each type, complete with sample pattern files
and output. |
|
For each topic, there is a brief description of the page, a list of
items of interest, and a section detailing any special actions that you
must take before being able to use the page. You may want to consult Chapter
10, "Using search," of the Netscape Enterprise Server Administrator's
Guide for additional information about pattern variables, configuration
files, and pattern files. You can also see the Web
Publisher online help for search for details of the search
query language.
Note: Before you can see results from some of the examples here,
you need to have searchable data in your Web Publishing collection. See
Chapter 12, "Configuring web publishing," of the Netscape Enterprise
Server Administrator's Guide and the Web
Publisher online help for more information about Web Publisher and
the Web Publishing collection.
|
|
Standard query page
This is the standard query page that comes with the default Enterprise
Server installation.
Items of interest:
- JavaScript launches the Java-based Guided Search applet if Java is
enabled, otherwise it launches the advanced HTML query page.
- Hidden form elements set the NS-search-type and NS-max-records
variables.
- Most screen elements use variables from the userdefs.ini configuration
file.
The source
pattern file (NS-query.pat)
Display
the query page
A canned search query
This query is similar to the standard query page.
Items of interest:
- The collection is hidden from users.
- The collection is hardwired to a specific value.
The
source pattern file (NS-query-demo1.pat)
Display
the query page
The advanced HTML query
This is the query page that is is displayed when users who do not have
Java enabled click the Guided Search button on the standard search query
page.
Items of interest:
- The NS-collection-list macro lets users select multiple collections.
The standard query uses the NS-collection-list-dropdown macro,
which only accesses one collection at a time. You can specify multiple
collections in the HTML by using name-value pairs with this syntax:
NS-collection=yourCollectionName.
- The number of records to return is set to 80 (view the source to see
how the URL specifies this setting).
- The search results header uses a different pattern file.
The source
pattern file (NS-advquery.pat)
Display
the query page
Using a different header for the search results
The default results header (NS-tocstart.pat), record (NS-tocrec.pat), and
footer (NS-tocend.pat) pattern files are defined in the dblist.ini
configuration file, but you can define others. For example, you can specify
a different header NS-tocstart-pat directly from the URL.
Items of interest:
- You can specify a different search results header pattern file directly
from the URL.
- Javascript can define different headers for each collection on a per-collection
basis.
- User input can be used to determine which header to use.
The
source pattern file (NS-query-demo2.pat)
Display
the original header
Display
a different header
Search results pages
The standard search results page
This page uses three pattern files: NS-tocstart-pat defines
the header, NS-tocend-pat file defines the footer, and NS-tocrec-pat
defines the format for the repeating element in the results.
Items of interest:
- The $$tag macro displays the expression between brackets only
when $$tag has a value.
- In the HTML-tocstart.pat and HTML-tocend.pat files, the $$tag
macro outputs the Prev and Next buttons only if the $$NS-get-next
or $$NS-get-prev macros have a value, and these macros only have
values if there is next or previous results to look at.
- The search targets the Web Publishing collection, but for simplicity
does not use the Web Publishing collection's NS-tocstart-pat pattern
file.
The source
pattern file (HTML-tocstart.pat)
The source
pattern file (HTML-tocrec.pat)
The source
pattern file (HTML-tocend.pat)
Display
the search results
The Web Publisher search results page
The Web Publishing collection uses a specific record file for its search
results.
Items of interest:
- In the dblist.ini configuration file, the Web Publishing collection
is defined with the HTML-tocstart.pat header file, the WEBPUB-tocrec.pat
record file, and the HTML-tocend.pat footer pattern files.
- Pattern variables are assigned within JavaScript. Pattern variables
are conditionally replaced with strings if the variables have a value.
Use double quotes (") around the variable when doing an assignment:
var aValue = "$$pattern_variable".
- You can use any indexed attribute in the NS-tocrec-pat pattern
file. You can find the list of indexed attributes for any collection by
looking at the collection contents page.
The source
pattern file (WEBPUB-tocrec.pat)
Display
the Web Publishing search results
Display
the collection contents
Document display pages
Displaying the entire document as part of your search results
In special cases such as short classified ads, you may want to display
not just the attributes associated with the results (like score, title,
filename), but the entire document in the results. This is done by using
the $$NS-insert-doc macro, which inserts the HTML version of the
document into the page. Note that this should only be done with HTML documents.
Note: To test this, you need to create a collection of HTML
documents (code samples or classifieds, for example). Modify the dblist.ini
configuration file for this collection so that NS-tocrec-pat is
set to HTML-tocrec-demo1.pat before you search.
Items of interest:
- The $$NS-insert-doc macro inserts a highlighted document into the search
results.
- You can only do this with HTML documents.
- You must modify dblist.ini for this collection.
The
source pattern file (HTML-tocrec-demo1.pat)
Display the document
The standard document display page
You can display a single document from the search results list. To do
this, you use the $$NS-insert-doc macro in the display document pattern
file to create an envelope for HTML documents. This macro retrieves the
HTML document and inserts it onto the page as well as highlighting the
matching query terms in the document.
NS-doc-number and NS-docs-matched are part of the href generated by
the NS-get-highlighted-doc convenience macro. The documentation contains
a full listing of all the pattern variables that are legal to pass into
the service function.
Note: To test this, you need to create a collection of HTML
documents or use an existing HTML collection.
Items of interest:
- The $$NS-insert-doc macro displays the document.
- You can add summary data to the end of the highlighted display document.
- You can do pattern substitution in userdefs.ini.
- You can pass the $$NS-doc-number and $$NS-docs-matched
values by adding name-value pairs for each variable to the URL These variables
are not ordinarily available in the record display function of the search
service. They are generated by the NS-get-highlighted-doc macro
as part of a search, but by the time the record display is requested, the
state information for search is long gone. For example, look at the source
for HTML-tocrec-pat.
- You can use the $$NS-doc-href macro to define a base tag for
all of the HREFs in this document.
The source
pattern file (NS-query.pat)
Display the standard document
display page
Highlighted search query text in the displayed document
You can take advantage of all the attributes stored with content manager
data, such as the Web Publisher attributes, to display the attributes as
well as the HTML document. The attributes are displayed in a small colored
box to the left of the HTML source document.
Note: You need to change the dblist.ini entry for
NS-record-pat the Web Publishing collection to point to the HTML-record-demo1.pat
pattern file.
Items of interest:
- You can display any content manager attributes.
- You access the highlighted document by clicking on the icon to the
left of a document listing.
- All search terms are highlighted and a small summary of the document
is added to the end of the highlighted document.
The
source pattern file (HTML-record-demo1.pat)
Display the document with highlights
Collection contents
pages
The standard collection contents page
This the standard collection contents description page.
Items of interest:
- The $$writeList macro loops through the same section for each
collection description
- The NS-collection-alias and NS-collection variables
are part of the search.
The
source pattern file (HTML-descriptions.pat)
Display
the collection contents page
A variation on the collection contents page
This page is similar to the standard collection contents page, with
some attributes and display fields removed.
Items of interest:
- Fewer attributes and display fields.
The
source pattern file (HTML-descriptions-demo1.pat)
Display
the collection contents page