CFSEARCH |
Description
Searches Verity collections using ColdFusion or K2Server, whichever search engine a collection is registered by. (ColdFusion can also search collections that have not been registered, with the cfcollection tag.)
A collection must be created and indexed before this tag can return search results.

A collection can be created in these ways:

- With the cfcollection tag
- In the ColdFusion Administrator, which calls the cfcollection tag
- Externally, using a native Verity indexing tool, such as Vspider or MKVDK

A collection can be registered with ColdFusion in the following ways:

- With the cfcollection tag
- In the ColdFusion Administrator, which calls the cfcollection tag

A collection can be registered with K2Server by editing the k2server.ini file.

A collection can be indexed in the following ways:

- In ColdFusion, with the cfindex tag
- In the ColdFusion Administrator, which calls the cfindex tag
- Using a native Verity indexing tool, such as Vspider or MKVDK

For more information, see Chapter 24, "Building a Search Interface," in Developing ColdFusion MX Applications.
Category
Extensibility tags

Syntax

    <cfsearch
       name = "search_name"
       collection = "collection_name"
       type = "criteria"
       criteria = "search_expression"
       maxRows = "number"
       startRow = "row_number"
       language = "language">

See also
cfcollection, cfexecute, cfindex, cfobject, cfreport, cfwddx
History

ColdFusion MX:

- Deprecated the external attribute. It might not work, and might cause an error, in later releases. (ColdFusion stores this information about each collection; it automatically detects whether a collection is internal or external.) This tag supports absolute (also known as fully qualified) collection pathnames and mapped collection names.
- Changed query result behavior: the cfindex tag can index the query results from a cfsearch operation.
- Changed Verity operations behavior: ColdFusion supports Verity operations on Acrobat PDF files.
- Changed multiple collection behavior: this tag can search multiple collections. In a multiple collection search, you cannot combine collections that are registered with K2Server and registered in another way.
- Changed acceptable collection naming: this tag accepts collection names that include spaces.
- Changed the following support: this tag supports Verity 2.6.1 and the LinguistX and ICU locales.
- Changed thrown exceptions: this tag can throw the SEARCHENGINE exception.

Usage

To permit application users to search Verity collections for non-standard strings, words or characters (for example, "AB23.45.67" or "--->") that would otherwise cause an error, you can create a text file that lists these elements and defines their formats for Verity. Name the file style.lex and put copies of the file in these directories:

- Windows:

- cf_root\lib\common\style (typically, cf_root = c:\cfusionmx)
- cf_root\lib\common\style\custom
- cf_root\lib\common\style\file

- Unix:

- cf_root/lib/common/style (typically, cf_root = /opt/coldfusionmx)
- cf_root/lib/common/style/custom
- cf_root/lib/common/style/file

Note: | To search for a character such as an angle bracket (< or >), you must use a criteria attribute value such as "&lt:" or "&lt:". The bracket characters are reserved in Verity, and using a backslash to escape the character (criteria="\<") does not work in this context. For more information, see Chapter 25, "Using Verity Search Expressions," in Developing ColdFusion MX Applications.

Macromedia does not recommend using the cflock tag with this tag; Verity provides the locking function. Using the cflock tag slows search performance.

This tag returns a record set whose columns you can reference in a cfoutput tag. For example, the following code specifies a search for the exact terms "filming" or "filmed":

    <cfsearch
    name = "mySearch"
    collection = "myCollection"
    criteria = '<WILDCARD>`film{ing,ed}`'
    type="explicit"
    startrow=1>
    <cfdump var = "#mySearch#>

In this example, the single quotation mark (') and backtick (`) characters are used as delimiters; for more information, see Chapter 25, "Using Verity Search Expressions," in Developing ColdFusion MX Applications.

cfsearch result columns

Variable | Description
--- | ---

    url

Value of URLpath attribute in the cfindex tag used to populate a collection. If type = "custom", the value is always empty when you populate a collection.

    key

Value of the attribute in the cfindex tag used to populate collection

    title

Value of title attribute in cfindex operation used to populate the collection, including PDF and Office document titles. If title is not provided, the tag uses the cfindex title attribute value for each row.

    score

Relevancy score of document based on search criteria

    custom1, custom2

Value of custom fields in cfindex operation used to populate collection.

    summary

Contents of automatic summary generated by cfindex.

Default: best three matching sentences, up to 500 characters.

    recordCount

Number of records returned in record set

    currentRow

Current row that cfoutput is processing

    columnList

List of column names within record set

    recordsSearched

Number of records searched

You can use query result columns in standard CFML expressions, preceding the result column name with the name of the query, as follows:

    #DocSearch.url#
    #DocSearch.key#
    #DocSearch.title#
    #DocSearch.score#

Example

    <!--- #1 (TYPE=SIMPLE) ----------------------------->
    <cfsearch
          name="name"
          collection="snippets,syntax,snippets"
          criteria="example" >
    <p>
    <cfoutput>Search Result total =  #name.RecordCount# </cfoutput><br>
    <cfoutput>
          url=#name.url#<br>
          key=#name.key#<br>
          title=#name.title#<br>
          score=#name.score#<br>
          custom1=#name.custom1#<br>
          custom2=#name.custom2#<br>
          summary=#name.summary#<br>
          recordcount=#name.recordcount#<br>
          currentrow=#name.currentrow#<br>
          columnlist=#name.columnlist#<br>
          recordssearched=#name.recordssearched#<br>
    </cfoutput>
    <cfdump var = #name#>
    <br>

    <!--- #2 (TYPE=EXPLICIT) ----------------------------->
    <cfsearch
          name = "snippets"
          collection = "snippets"
          criteria = '<wildcard>`film{ing,ed}`'
          type="explicit"
          startrow=1>
    <cfoutput
          query="snippets">
          url=#url#<br>
          key=#key#<br>
          title=#title#<br>
          score=#score#<br>
          custom1=#custom1#<br>
          custom2=#custom2#<br>
          summary=#summary#<br>
          recordcount=#recordcount#<br>
          currentrow=#currentrow#<br>
          columnlist=#columnlist#<br>
          recordssearched=#recordssearched#<br>
    </cfoutput>
    <cfdump var = #snippets#>
    <br>

    <!--- #3 (search by CF key) ----------------------------->
    <cfsearch
          name = "book"
          collection = "custom_book"
          criteria = "cf_key=bookid2">
    <cfoutput>
          url=#book.url#<br>
          key=#book.key#<br>
          title=#book.titleE#<br>
          score=#book.score#<br>
          custom1=#book.custom1#<br>
          custom2=#book.custom2#<br>
          summary=#book.summary#<br>
          recordcount=#book.recordcount#<br>
          currentrow=#book.currentrow#<br>
          columnlist=#book.columnlist#<br>
          recordssearched=#book.recordssearched#<br>
    </cfoutput>
    <cfdump var = #book#>
    <br>

NAME |
| Required
Name of the search query.

COLLECTION |
| Required

One or more path(s) and/or registered collection name(s).

For a registered collection, specify the collection name.

For an unregistered collection, specify an absolute path.

Registered names are listed in the ColdFusion Administrator, Verity Collections and Verity Server pages.

To specify multiple collections, use a comma delimiter. For example: "CFUSER, e:\collections\personnel"

If you specify multiple collections, you cannot include a combination of collections that are registered by K2Server and registered by Verity.

TYPE |
| Optional

Default value: "simple "

- simple: STEM and MANY operators are implicitly used. See Chapter 25, "Using Verity Search Expressions," in Developing ColdFusion MX Applications.
- explicit: operators must be invoked explicitly

CRITERIA |
| Optional
Search criteria. Follows the syntax rules of the type attribute. If you pass a mixed-case entry in this attribute, the search is case-sensitive. If you pass all uppercase or all lowercase, the search is case-insensitive. Follow Verity syntax and delimiter character rules; see Chapter 25, "Using Verity Search Expressions," in Developing ColdFusion MX Applications.

MAXROWS |
| Optional
Default value: "All" Maximum number of rows to return in query results. Use double or single quotation marks.

STARTROW |
| Optional
Default value: "1" First row number to get.

LANGUAGE |
| Optional
Default value: "english" For options, see cfcollection. Requires the ColdFusion International Search Pack.