Use the CFX_SEARCH tag to execute searches against indexed data in Verity collections. Collections must be created and populated before any searches can be executed.
Conducting a basic search is very straightforward using the CFX_SEARCH tag. In the following example, a simple search for the word "database" is performed on a collection called "DOCS."
<CFX_SEARCH NAME="DocSearch" COLLECTION="DOCS" TYPE="Simple" CRITERIA="database">You use the CFOUTPUT tag to present the results of your search to your user. The following example shows a CFOUTPUT example, complete with fully defined URL:
<CFOUTPUT QUERY="DocSearch"> <A HREF="#DocSearch.url#">#DocSearch.Title#</A><BR> </CFOUTPUT>
Every search conducted with the CFX_SEARCH tag returns, as part of the result set, four result columns you can reference in your CFOUTPUT:
- URL - Returns the value of the URLPATH attribute defined in the CFX_INDEX tag used to populate the collection. This value is always empty when you populate the collection with CFX_INDEX with TYPE=CUSTOM.
- KEY - Returns the value of the KEY attribute defined in the CFX_INDEX tag used to populate the collection
- TITLE - Returns the value of the TITLE attribute defined by the <TITLE> HTML tag in any HTML or Cold Fusion template file that was indexed by CFX_INDEX. If the collection was TYPE=CUSTOM, TITLE returns the value of the TITLE attribute defined by the CFX_INDEX tag. If the collection was TYPE=FILE, TITLE also returns the value of the TITLE attribute defined by the CFX_INDEX tag.
- SCORE - Returns the relevancy score of the document based on the search criteria
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#