ColdFusion 9.0 Resources |
cfcollectionSyntax<cfcollection action = "action" categories = "yes|no" collection = "collection name" engine = "verity|solr language = "language" name = "query name" path = "c"> Note: You can specify
this tag’s attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
HistoryColdFusion 9: Added the engine attribute (required for Solr support). ColdFusion MX 7:
ColdFusion MX:
Attributes
UsageWith this tag you can
The following table shows the dependence relationships among this tag’s attribute values:
The following examples show the structures returned by the categorylist action:
The list action returns the following information in a result set that contains one row per collection:
You can also specify uni to enable support for multiple languages. If the Verity Server is not running when the list action is executed on a Verity collection, the tag throws an error. To determine whether a collection exists, use code, such as the following, to execute a query of queries: <cfcollection action="list" name="myCollections" > <cfquery name="qoq" dbtype="query"> SELECT * from myCollections WHERE myCollections.name = 'myCollectionName' </cfquery> <cfif qoq.recordcount GT 0> <!--- Collection exists ---> <cfdump var = #qoq#> </cfif> To get a result set with values for all the collections that are registered with the search server, use code such as the following: <cfcollection action="list" name="myCollections"> <cfoutput query="myCollections"> #name#<br> </cfoutput> To add content to a collection, use cfindex. To search a collection, use cfsearch. You cannot delete Verity collections on Windows if they are created outside of the ColdFusion collections directory or on a drive other than C:, D: or E:. To use a different drive letter, edit the cf_dir/verity/common/verity.cfg file and replace an entry with the directory you wish to use as follows: alias11=path6 mapping11=F:\ dirmode11=rw Restart the ColdFusion Search Service for this change to take effect. For Solr collections, the language attribute of this tag supports the following options:
For Verity collections, the language attribute of this tag supports the following options:
The default location for all collections is as follows:
Example<!------------------------------------------------------------------------- (coll_actn.cfm) Check for server platform and use its default Verity Collection directory. If you did not install ColdFusion in the default directory, or if you use the J2EE configuration, or if your webroot is not C:\ColdFusion9\wwwroot, you might need to change the path in this example. For example, for JRun4 the path might be C:\JRun4\Verity\Collections\ ---------------------------------------------------------------------------> <cfif Find("Windows", Server.OS.Name)> <cfset collPath = "C:\JRun4\Verity\Collections\"> <cfelse> <cfset collpath = "/opt/coldfusion9/verity/collections/"> </cfif> <!-------------------------------------------------------------------------- Process form input and do the requested cfcollection operation. ---------------------------------------------------------------------------> <cfif IsDefined("form.CollectionName") AND IsDefined("form.CollectionAction")> <cfif form.CollectionName is not ""> <cfswitch expression="#FORM.CollectionAction#"> <cfcase value="Create"> <cfcollection action="CREATE" collection="#FORM.CollectionName#" path="#collPath#" categories="yes"> <h3>Collection created.<br> Use CFINDEX to populate it.</h3> </cfcase> <cfcase value="Repair"> <cfcollection action="REPAIR" collection="#FORM.CollectionName#"> <h3>Collection repaired.</h3> </cfcase> <cfcase value="Optimize"> <cfcollection action="OPTIMIZE" collection="#FORM.CollectionName#"> <h3>Collection optimized.</h3> </cfcase> <cfcase value="Delete"> <cfcollection action="DELETE" collection="#FORM.CollectionName#"> <h3>Collection deleted.</h3> </cfcase> </cfswitch> <cfelse> <h3>Please enter a name for your collection</h3> </cfif> </cfif> <!-------------------------------------------------------------------- (coll_form.cfm) Form to specify the collection name and action coll_form.cfm ---------------------------------------------------------------------> <form action="coll_actn.cfm" method="POST" > <select name="CollectionAction"> <option value="Create">Create this collection <option value="Optimize">Optimize this collection <option value="Repair">Repair this collection <option value="Delete">Delete this collection </select> <p><strong>Collection on which to act</strong><br> Use the default value or enter your own Collection name<br> <input type="Text" name="CollectionName" value="My_coll"></p> <input type="Submit" name="" value="alter or create my collection"> </form> |