Executes searches against data indexed in Verity collections. Collections can be created by calling the cfcollection tag, by using the ColdFusion Administrator, or through native Verity indexing tools. Collections are populated with data either with the cfindex tag, or externally, using native Verity indexing tools. Collections must be created and populated before any searches can be executed.
<cfsearch name = "search_name" collection = "collection_name" type = "criteria" criteria = "search_expression" maxRows = "number" startRow = "row_number" external = "Yes" or "No" language = "language">
cfcollection, cfreport, cfexecute, cfgraph, cfservlet, cfindex, cfservletparam, cfobject, cfwddx
In the criteria attribute, if you pass a mixed case entry, case sensitivity is applied to the search. If you pass all upper or all lower case, case insensitivity is assumed.
Every search conducted with the cfsearch tag returns, as part of the record set, a number of result columns you can reference in your cfoutput.
You can use these result columns in standard CFML expressions, preceding the result column name with the name of the query:
#DocSearch.url#
#DocSearch.key# #DocSearch.title# #DocSearch.score#
<!--- This example shows how to utilize cfsearch
to search an existing, populated collection --->
<html>
<head>
<title>
cfsearch Example
</title>
</head>
<body bgcolor = silver>
<H3>cfsearch Example</H3>
<!--- To index the collection, select the check box
on the form --->
<cfif IsDefined("form.IndexCollection")>
<!--- Change key and URLpath to reflect accurate key and URL
<cfindex action = "update" collection = "Snippets"
key = "c:\inetpub\wwwroot\cfdocs\snippets" type = "path"
title = "This is my test" URLpath = "http://127.0.0.1/cfdocs/snippets/"
extensions = ".cfm" recurse = "Yes">
<H3>Collection re-indexed</H3>
</cfif>
<cfif IsDefined("form.source") AND
IsDefined("form.type") AND IsDefined("form.searchstring")>
<!--- actually conduct the search --->
<cfsearch name = "SearchSnippets"
collection = "#form.source#"
type = "#form.type#"
criteria = "#form.searchstring#">
<!--- print out the search results --->
<cfoutput>
<H2>#form.type# Search Results</H2>
<P>#SearchSnippets.recordCount# "hit
<cfif SearchSnippets.recordcount is not 1>s</cfif>" found
out of #SearchSnippets.RecordsSearched# total record
<cfif SearchSnippets.recordcount is not 1>s</cfif>
searched.
<P><I><B>#form.maxrows# records returned ...</B></I>
<cftable query = "SearchSnippets" maxRows = "#maxrows#"
startRow = "1" colHeaders HTMLTable>
<cfcol header = "SCORE" text = "#score#">
<cfcol header = "TITLE"
text = "<a href = '#url#' target = 'blank'>#title#</A>">
<cfcol header = "SUMMARY" text = "#summary#">
</cftable>
</cfoutput>
</cfif>
...