
485
DEVELOPING
COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Las
t
upda
te
d 8/5/2010
Indexing a collection by using the cfindex tag
You can index a collection in CFML by using the
cfindex
tag, which eliminates the need to use the ColdFusion
Administrator. The
cfindex
tag populates the collection with metadata that is then used to retrieve search results. You
can use the
cfindex
tag to index either physical files (documents stored within your website’s root folder), or the
results of a database query.
Note:
Before indexing a collection, create a Verity collection by using the ColdFusion Administrator, or the
cfcollection
tag. For more information, see “
Creating a collection with the ColdFusion Administrator
” on page
481,
or “
Creating a collection with the cfcollection tag
” on page
482.
When using the
cfindex
tag, the following attributes correspond to the values that you would enter by using the
ColdFusion Administrator to index a collection:
You can use form and action pages like the following examples to select and index a collection.
Select which collection to index
1
Create a ColdFusion page with the following content:
Attribute
Description
collection
The name of the collection.
action
Specifies what the
cfindex
tag should do to the collection. The default
action
is to update the collection,
which generates a new index. Other
actions
are to delete, purge, or refresh the collection.
type
Specifies the type of files or other data to which the
cfindex
tag applies the specified action. The value you
assign to the
type
attribute determines the value to use with the
key
attribute (see the following list). When you
enter a value for the
type
attribute,
cfindex
expects a corresponding value in the
key
attribute. For example,
if you specify
type=file
,
cfindex
expects a directory path and filename for the
key
attribute.
The
type
attribute has the following possible values:
•
file
: Specifies a directory path and filename for the file that you are indexing.
•
path
: Specifies a directory path that contains the files that you are indexing.
•
custom
: Specifies custom data, such as a recordset returned from a query.
extensions
(Optional) The delimited list of file extensions that ColdFusion uses to index files if
type="path".
key
The value that you specify for the
key
attribute depends on the value set for the
type
attribute:
•
If
type="file"
, the
key
is the directory path and filename for the file you are indexing
.
•
If
type="path"
, the
key
is the directory path that contains the files you are indexing
.
•
If
type="custom"
, the
key
is a unique identifier specifying the location of the documents you are indexing;
for example, the URL of a specific web page or website whose contents you want to index
.
If you are indexing
data returned by a query (from a database for example), the
key
is the name of the recordset column that
contains the primary key.
URLpath
(Optional) The URL path for files if
type="file"
and
type="path"
. When the collection is searched with the
cfsearch tag, ColdFusion works as follows:
•
type="file"
: The
URLpath
attribute contains the URL to the file.
•
type="path"
: The path name is automatically prefixed to filenames and returned as the
URLpath
attribute.
recurse
(Optional)
Yes
or
No
. If
type = "path"
,
Yes
specifies that directories below the path specified in the key
attribute are included in the indexing operation.
language
(Optional) The language of the collection. The default language is English Basic.
To learn more about support for languages, see “
Specifying a language
” on page
479.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...