Now that you've created and indexed a searchable data source, you need to build a search interface to allow users to access the data source. The CFSEARCH tag provides users with a set of operators and modifiers to create sophisticated query expressions. We'll explore these options in detail below, but first let's take a look at getting a basic search application up and running.
To quickly create a search application for an existing collection, click the File > New command in ColdFusion Studio and select the Verity Wizard in the CFML tab of the New Document dialog. The wizard creates a set of application pages based on the entries you make in the wizard dialogs.
You can customize the search interface by adding instructional text for users and applying styles to the form pages.
![]() |
To search the collection: |
<HTML> <HEAD> <TITLE>Select the collection to search</TITLE> </HEAD> <BODY> <H2>Search</H2> <FORM METHOD="Post" ACTION="collectionsearchaction.cfm"> <P>Enter the collection you want to search: <INPUT TYPE="text" NAME="collection" SIZE="25" MAXLENGTH="35"></ P> <P>Select the type of search:<BR> <INPUT TYPE=radio NAME=type VALUE=Simple checked> Simple<BR> <INPUT TYPE=radio NAME=type VALUE=Explicit> Explicit<BR> <P>Enter a search string:</P> <INPUT TYPE=text NAME=searchstring SIZE=50> <P><INPUT TYPE=submit NAME=search1 VALUE="Search"> <INPUT TYPE=reset VALUE="Reset"> </FORM> </BODY> </HTML>
collectionsearchform.cfm
.
![]() |
To present the results of the search to the user: |
<HTML> <HEAD> <TITLE>Search output template</TITLE> </HEAD> <BODY> <CFSEARCH NAME="Search1" COLLECTION="#form.collection#" FORM TYPE="#form.type#" CRITERIA="#form.searchstring#"> <H2>Search Results</H2> <CFOUTPUT> #Search1.RecordCount# found out of #Search1.RecordsSearched# searched. </CFOUTPUT> <HR NOSHADE> <CFOUTPUT QUERY="Search1"> <A HREF="#Search1.URL#">#Search1.title#</A><BR> </CFOUTPUT> <HR NOSHADE> </BODY> </HTML>
collectionsearchaction.cfm
.
collectionsearchform.cfm
in your browser, enter values in the form, then submit it.
As part of the indexing process, Verity automatically produces a summary of every document file or query result set. The default summarization selects the best sentences, based on internal rules, up to a maximum of 500 characters. Summarization information is returned by default with every CFSEARCH operation. For more information on this topic, see the Allaire Knowledge Base article, "Custom1, Custom2 and Summary Fields" (ID# 1081) on our Web site at http://www.allaire.com/Support/KnowledgeBase/SearchForm.cfm.
To access the summary, invoke the property in the following form:
#search_query.Summary#
For example, in a search operation where the value of the NAME attribute is "mysearch" the following CFML outputs the summary of the search results:
<CFOUTPUT QUERY="mysearch"> #Summary#<BR> </CFOUTPUT>
For information on an advanced summarization technique, see the Allaire Knowledge Base article, "Synchronizing information stored in Verity Collection Document Fields with Corresponding Data from a Database" (ID# 1161) on our Web site at http://www.allaire.com/Support/KnowledgeBase/SearchForm.cfm.
Three properties are generated for each CFSEARCH query that provide information about a particular query: