Creating a Search Interface


After you've created a collection and indexed it, you need to provide end users with a means to interface with it. Use the <CFSEARCH> tag to search for a collection. This tag executes a search and returns the result that can be used for the <CFOUTPUT> and <CFLOOP> tags for further processing. <CFSEARCH> can also search collections of indexes of documents, or indexes of query results. Here's the syntax for <CFSEARCH>:

 <CFSEARCH NAME="search_name"     COLLECTION="collection_name"     TYPE="criteria"     CRITERIA="search_expression"     MAXROWS="number"     STARTROW="row_number"     EXTERNAL="Yes/No"     LANGUAGE="language"> 

<CFSEARCH> has the following attributes:

  • NAME. This is a required attribute. It specifies the name for the search query.

  • COLLECTION. This is a required attribute. It specifies the logical collection name, which is the target of the search operation or an external collection with a fully qualified path. Collection names are defined by using either <CFCOLLECTION> or ColdFusion Administrator. Multiple ColdFusion collections can be specified in a comma-separated list, as follows:

     COLLECTION="CFNAME, CFLANG" 

    To search an external collection, EXTERNAL="Yes", specify the collection name, including the fully qualified path:

     COLLECTION="d:\collections\people" 

    If multiple collections are specified in the COLLECTION attribute and the value for the EXTERNAL attribute is Yes, generate all the specified collections externally. You cannot combine internal and external collections in the same search operation.

  • TYPE. This is an optional attribute and specifies the criteria type for the search. Here are the valid entries:

    • SIMPLE. By default, the operators STEM and MANY are used.

    • EXPLICIT. This specifies that all operators must be invoked explicitly.

  • CRITERIA. This is an optional attribute. It specifies the criteria for the search following the syntactic rules specified by TYPE.

  • MAXROWS. This is an optional attribute. It specifies the maximum number of entries for index queries. If omitted, all rows are returned.

  • STARTROW. This is an optional attribute. It specifies the first row number to be retrieved. The default is 1.

  • EXTERNAL. This is an optional attribute that can take two values, Yes or No. Yes indicates that the collection you're searching was created outside ColdFusion using native Verity indexing tools. The default is No.

  • LANGUAGE. This is an optional attribute. It specifies the language for use. To use this attribute, you must have the ColdFusion International Search Pack installed. The default language is English.

If you pass a mixed-case entry (mixed upper- and lowercase) in the CRITERIA attribute, case sensitivity is applied to the search. If you pass all upper- or lowercase letters, case sensitivity isn't applied.

Every search conducted with <CFSEARCH> returns a number of result columns that you can reference in your <CFOUTPUT>:

  • URL. Returns the value of the URLPATH attribute defined in the CFINDEX operation used to populate the collection. This value is always empty when you populate the collection with CFINDEX, when TYPE is Custom.

  • KEY. Returns the value of the KEY attribute defined in the CFINDEX operation used to populate the collection.

  • TITLE. Returns the value of the TITLE attribute in the CFINDEX operation used to populate the collection. This includes the titles of PDF and Office documents. If no title is provided in the TITLE attribute, CFSEARCH returns CF_TITLE.

  • SCORE. Returns the relevancy score of the document based on the search criteria.

  • CUSTOM1 and CUSTOM2. Return the value placed in the custom fields in the CFINDEX operation used to populate the collection.

  • SUMMARY. Returns the contents of the automatic summary generated by CFINDEX. The default summarization selects the best three matching sentences, up to a maximum of 500 characters.

  • RECORDCOUNT. Returns the number of records returned in the record set.

  • CURRENTROW. Returns the current row being processed by CFOUTPUT.

  • COLUMNLIST. Returns the list of column names within the record set.

  • RECORDSSEARCHED. Returns the number of records searched.

You can use these result columns in standard CFML expressions, preceding the result column name with the name of the query.




Macromedia ColdFusion MX. Professional Projects
ColdFusion MX Professional Projects
ISBN: 1592000126
EAN: 2147483647
Year: 2002
Pages: 200

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net