cfsearch

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:

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

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

A collection can be indexed in the following ways:

For more information, see Building a Search Interface in Developing ColdFusion MX Applications.

Extensibility tags

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

cfcollection, cfexecute, cfindex, cfobject, cfreport, cfwddx

ColdFusion MX:

Attribute Req/Opt Default Description

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

simple

  • simple: STEM and MANY operators are implicitly used. See 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 Using Verity Search Expressions in Developing ColdFusion MX Applications.

maxRows

Optional

All

Maximum number of rows to return in query results. Use double or single quotation marks.

startRow

Optional

1

First row number to get.

language

Optional

english

For options, see cfcollection. Requires the ColdFusion International Search Pack.

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:

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 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 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#

<!--- #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>

View comments on LiveDocs