Field searches

Fields are extracted from the document and stored in the collection for retrieval and searching, and can be returned on a results list. Zones, on the other hand, are merely the definitions of "regions" of a document for searching purposes, and are not physically extracted from the document in the same way that fields are extracted.

You must define a region of text as a zone before it can be a field. Therefore, it can be only a zone, or it can be both a field and a zone. Whether you define a region of text as a zone only or as both a field and a zone depends on your particular requirements.

A field must be defined in the style file, style.ufl, before you create the collection. To map zones to fields (to display field data), you must define and add these extra fields to style.ufl.

You can specify the values for the cfindex attributes TITLE, KEY, URL, and CUSTOM as document fields for use with relational operators in the criteria attribute. (The SCORE and SUMMARY attributes are automatically returned by a cfsearch; these attributes are different for each record of a collection as the search criteria changes.) Text comparison operators can reference the following document fields:

To explore how to use document fields to refine a search, consider the following database table, named Calls. This table has four fields and three records, as the following table shows:

call_ID Problem_Description Short_Description Product

1

Can't bold text properly under certain conditions

Bold Problem

HomeSite+

2

Certain optional attributes are acting as required attributes

Attributes Problem

ColdFusion

3

Can't do a File/Open in certain cases

File Open Problem

HomeSite+

A Verity search for the word certain returns three records. However, you can use the document fields to restrict your search; for example, a search to retrieve HomeSite+ problems with the word certain in the problem description.

These are the requirements to run this procedure:

The following table shows the relationship between the database column and cfindex attribute:


Database column
The cfindex
attribute

Comment

call_ID

key

The primary key of a database table is often a key attribute.

Problem_Description

body

This column is the information to be indexed.

Short_Description

title

A short description is conceptually equivalent to a title, as in a running title of a journal article.

Product

custom1

This field refines the search.

You begin by selecting all data in a query:

<cfquery name = "Calls" datasource = "MyDSN">
   Select * from Calls
</cfquery>

The following code shows the cfindex tag for indexing the collection (the type attribute is set to custom for tablular data):

<cfindex
   query = "Calls"
   collection = "training"
   action = "UPDATE"
   type = "CUSTOM"
   title = "Short_Description"
   key = "Call_ID"
   body = "Problem_Description"
   custom1 = "Product">

To perform the refined search for HomeSite+ problems with the word certain in the problem description, the cfsearch tag uses the CONTAINS operator in its criteria attribute:

<cfsearch
   collection = "training"
   name = "search_calls"
   criteria = "certain and CF_CUSTOM1 <CONTAINS> HomeSite">

The following code displays the results of the refined search:

<table border="1" cellspacing="5">
<tr>
   <th align="LEFT">KEY</th>
   <th align="LEFT">TITLE</th>
   <th align="LEFT">CUSTOM1</th>
</tr>

<cfoutput query = "search_calls">
<tr>
   <td>#KEY#</td>
   <td>#TITLE#</td>
   <td>#CUSTOM1#</td>
</tr>
</cfoutput>
</table>

View comments on LiveDocs