CFSEARCH | |||||||||||||||||||||||||||||||||||||
Description
Searches one or more Verity collections. A collection must be created and indexed before this tag can return search results. A collection can be created in these ways:
If you use a native Verity tool to create a collection, it must be registered. A collection can be registered with ColdFusion in the following ways:
A collection can be indexed in the following ways:
For more information, see Chapter 24, "Building a Search Interface" in ColdFusion MX Developer's Guide. |
|||||||||||||||||||||||||||||||||||||
Category
Extensibility tags | |||||||||||||||||||||||||||||||||||||
Syntax<cfsearch name = "search_name" collection = "collection_name" category = "category[,category2,...]" categoryTree = "tree_location" status = "" type = "criteria" criteria = "search_expression" maxRows = "number" startRow = "row_number" suggestions = "suggestion_option" contextPassages = "number_of_passages" contextBytes = "number_of_bytes" contextHighlightBegin = "html_string" contextHighlightEnd = "html_string" previousCriteria = "criteria" language = "language"> |
|||||||||||||||||||||||||||||||||||||
See also
cfcollection, cfexecute, cfindex, cfobject, cfreport, cfwddx |
|||||||||||||||||||||||||||||||||||||
History
ColdFusion MX 7:
ColdFusion MX:
|
|||||||||||||||||||||||||||||||||||||
Usage
The cfsearch tag returns a query object 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 maxrows = "100"> <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 ColdFusion MX Developer's Guide. To optimize search performance, always specify the maxrows attribute, setting it to a value that matches your application's needs. A value less than 300 helps to ensure optimal performance. Macromedia does not recommend using the cflock tag with this tag; Verity provides the locking function. Using the cflock tag slows search performance. |
|||||||||||||||||||||||||||||||||||||
The cfsearch tag result columns
|
|||||||||||||||||||||||||||||||||||||
Status structure keys
To permit application users to search Verity collections for nonstandard 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:
In the multiserver and J2EE configurations, you install Verity in a separate directory.
|
|||||||||||||||||||||||||||||||||||||
Example<!--- #1 (TYPE=SIMPLE) -----------------------------> <cfsearch name="name" collection="snippets,syntax,snippets" criteria="example" maxrows = "100"> <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 maxrows = "100"> <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" maxrows = "100"> <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#> |
NAME | |
Required | |
Name of the search query. |
COLLECTION | |
Required | |
One or more collection names. You can specify more than one collection unless you are performing a category search (that is, specifying category or categoryTree). |
CATEGORY | |
Optional | |
A list of categories, separated by commas, to which the search is limited. If specified, and the collection does not have categories enabled, ColdFusion throws an exception. |
CATEGORYTREE | |
Optional | |
The location in a hierarchical category tree at which to start the search. ColdFusion searches at and below this level. If specified, and the collection does not have categories enabled, ColdFusion throws an exception. Can be used in addition to the category attribute. |
STATUS | |
Optional | |
Specifies the name of the structure variable into which ColdFusion places search information, including alternative criteria suggestions (spelling corrections). For a list of keys in this structure, see "Status structure keys" on page 636. |
TYPE | |
Optional | |
Default value: "simple "
Used to specify the parser that Verity uses to process the criteria.
For more information, see Chapter 25, "Using Verity Search Expressions" in ColdFusion MX Developer's Guide. Also see your Verity documentation. |
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 ColdFusion MX Developer's Guide. |
MAXROWS | |
Optional | |
Default value: "All"
Maximum number of rows to return in query results. |
STARTROW | |
Optional | |
Default value: "1"
First row number to get. |
SUGGESTIONS | |
Optional | |
Default value: "never"
Specifies whether Verity returns spelling suggestions for possibly misspelled words. Use one of the following options:
There is a small performance penalty for retrieving suggestion data. |
CONTEXTPASSAGES | |
Optional | |
Default value: "0"
The number of passages/sentences Verity returns in the context summary (that is, the context column of the results). The default i s 0, which disables context summary. |
CONTEXTBYTES | |
Optional | |
Default value: "300"
The maximum number of bytes Verity returns in the context summary. |
CONTEXTHIGHLIGHTBEGIN | |
Optional | |
Default value: "<b>"
The HTML to prepend to search terms in the context summary. Use this attribute in conjunction with contextHighlightEnd to highlight search terms in the context summary. |
CONTEXTHIGHLIGHTEND | |
Optional | |
Default value: "</b>"
The HTML to append to search terms in the context summary. Use this attribute in conjunction with contextHighlightBegin to highlight search terms in the context summary. |
PREVIOUSCRITERIA | |
Optional | |
The name of a result set from an existing set of search results. Verity searches the result set for criteria without regard to the previous search score or rank. Use this attribute to implement searching within result sets. |
LANGUAGE | |
Optional | |
Default value: "english"
Deprecated. This attribute is now ignored and the language of the collection is used to perform the search. |