Adobe COLDFUSION 9 Manual page 522

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Operator
Description
CONTAINS
Selects documents by matching the word or phrase that you specify
with the values stored in a specific document field. Documents are
selected only if the search elements specified appear in the same
sequential and contiguous order in the field value.
MATCHES
Selects documents by matching the query string with values stored in
a specific document field. Documents are selected only if the search
elements specified match the field value exactly. If a partial match is
found, a document is not selected. When you use the MATCHES
operator, you specify the field name to search, and the word, phrase,
or number to locate. You can use ? and * to represent individual and
multiple characters, respectively, within a string.
STARTS
Selects documents by matching the character string that you specify
with the starting characters of the values stored in a specific
document field.
ENDS
Selects documents by matching the character string that you specify
with the ending characters of the values stored in a specific
document field.
SUBSTRING
Selects documents by matching the query string that you specify
with any portion of the strings in a specific document field.
For example, assume a document field named SOURCE includes the following values:
• Computer
• Computerworld
• Computer Currents
• PC Computing
To locate documents whose source is Computer, enter the following:
SOURCE <MATCHES> computer
To locate documents whose source is Computer, Computerworld, and Computer Currents, enter the following:
SOURCE <MATCHES> computer*
To locate documents whose source is Computer, Computerworld, Computer Currents, and PC Computing, enter the
following:
SOURCE <MATCHES> *comput*
For an example of ColdFusion code that uses the CONTAINS relational operator, see
You can use the SUBSTRING operator to match a character string with data stored in a specified data source. In the
example described here, a data source called TEST1 contains the table YearPlaceText, which contains three columns:
Year, Place, and Text. Year and Place make up the primary key. The following table shows the TEST1 schema:
Last updated 8/5/2010
Example
In a document field named TITLE, to retrieve
documents whose titles contain music, musical,
or musician, search for TITLE <CONTAINS> Musi*.
To retrieve CFML and HTML pages whose meta
tags contain Framingham as a content word,
search for KEYWORD <CONTAINS> Framingham.
For examples, see the text immediately following
this table.
In a document field named REPORTER, to retrieve
documents written by Clark, Clarks, and Clarkson,
search for REPORTER <STARTS> Clark.
In a document field named OFFICER, to retrieve
arrest reports written by Tanner, Garner, and Milner,
search for OFFICER <ENDS> ner.
In a document field named TITLE, to retrieve
documents whose titles contain words such as
solution, resolution, solve, and resolve, search for
TITLE <SUBSTRING> sol.
"Field
searches" on page 523.
517

Advertisement

Table of Contents
loading

Table of Contents