The search module makes it easy to specify which data you want to search, to
build the search index, and to test the search index.
To import the search module into your application, click the File menu,
choose New, and then Module. Select the search module from the list of available
modules, and click Install.
When the installation is complete, navigate to the wsSearch folder in the
root of your web. Clicking the wsSearch folder displays the module.
The first thing you need to do is define your search specification, by adding
one or more catalogs.
Adding a Catalog
A catalog defines a set of records to be indexed for full-text search. You can index the data in an entire table, or specify a subset of records or fields in the table to be indexed. You must add a catalog for each table that you want to index.
To add a catalog, click the Add Catalog button in the module. You'll be
prompted to set properties for the catalog.
All of the properties that you can set for a catalog are optional. The catalog
properties are described below:
||Shows which table is to be indexed for this catalog.
|| Specifies which field should be used for the title in the search results. If you omit this value, the search module uses the table's primary key.
||Specifies which field should be used for the summary in the search results.
|Fields to Search
||Specifies which fields in the table to index.
||Defines a filter for the data in the table. Only records that meet the filter criteria will be indexed. You can use standard SQL-compatible syntax to specify the filter criteria.
||Specifies which view to use in the URL that appears in the search results. By default, the display view is the default.view file in the data folder of the table on which the catalog is based. For example, if you index the AddressBook table, the default display view is /AddressBook/default.view, but you can set the Display View property to use a different view.
Building the Search Index
Once you've defined the catalogs to be searched, you must build the search
index. Click the Build Search Index button to build the search index.
To delete the search index, click the Delete Search Index button. You don't
need to delete the search index before you rebuild it; the existing search index
will automatically be overwritten.
To test your search index as it will appear to your users, click the Preview tab and enter your search query into the search dialog.
You can use the Script Scheduler module to set up a regularly scheduled task to
regenerate the search index. The Script Scheduler module is available in the DataWeb Application Gallery. Import the Script Scheduler module into your web and
insert a new scheduled script. The function that you want to call from the
Script Scheduler is the BuildSearchIndex() function, available in the file
Returning Search Results
The search module contains two components, searchbox.view and
searchresults.view, that you can add to a view to create a custom search page
for your application. These are the same components that are displayed on the
Test Search Index tab.
In your view, choose Component from the Insert menu, and select the
appropriate search component. You may want to set your view's template to
TwoColumn.view to make it easy to arrange the components on the page.
The searchbox.view component has several optional settings that you can
customize for each view that contains it:
|Display This Results Page
||Specifies the page for the results
to be output. If you leave this setting blank, and your view
includes the searchresults.view component, then search results
will be displayed on the same page.
|Show Results from This Catalog
|| Specifies the catalog or catalogs
from which results are displayed. To specify more than one
catalog, separate the catalog names with semicolons. If you leave
this setting blank, results from all catalogs are displayed.
|Search Box Width
||Specifies the width of the search
|Search Box Input
||Specifies the width of the search
box text input.
|Build Index on Demand
||Specifies whether to build
the search index if it does not exist when the user attempts to
search it. By default, this option is set to False. If your search
specification includes a large number of rows, it may take several
minutes to build. In that case, you may want to leave this option
set to False.