cfcollection

Description

Creates and administers Verity or Solr search engine collections.

Categories

Related

History

ColdFusion 9: Added the engine attribute (required for Solr support). ColdFusion MX 7: Starting with ColdFusion MX 7, you cannot use the cfcollection tag to create alias names for existing collections. Because Verity maintains all the collection information, you cannot have two names point to the same collection. Removed reference to external collections. Deprecated the map and repair options of the action attribute. They might not work, and might cause an error, in later releases. Added categories attribute and categorylist action. Added CATEGORIES, SIZE, DOCCOUNT, and LASTMODIFIED to list of variables returned by the list action. Marked as obsolete the MAPPED, ONLINE, and REGISTERED variables returned by the list action. ColdFusion MX: Changed the requirements for the action attribute: it is now required. Added the action attribute list value. It is the default. Changed the requirements for the action attribute value map: it is not necessary to specify the action attribute value map. (ColdFusion detects collections and creates maps collections as required.) Changed acceptable collection naming: this tag accepts collection names that include spaces. Changed Verity operations behavior: ColdFusion supports Verity operations on Acrobat PDF files. Changed thrown exceptions: this tag can throw the SEARCHENGINE exception.

Syntax

<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.

Attributes

AttributeDescriptionRequiredDefault
actioncategorylist: (Verity only) retrieves categories from the collection and indicates how many documents are in each one. Returns a structure of structures in which the category representing each substructure is associated with a number of documents. For a category in a category tree, the number of documents is the number at or below that level in the tree. create: registers the collection with ColdFusion. If the collection is present, the tag creates a map to it. If the collection is not present, the tag creates it. delete: unregisters a collection and deletes its directories. list: returns a query result set, named from the name attribute value, of the attributes of the collections that are registered by ColdFusion. If you have Solr and Verity collections and omit the engine attribute, ColdFusion lists information for both types of collections. map: creates a map to a collection. If the action is create and the collection exists, ColdFusion also creates a map to the collection. optimize: optimizes the structure and contents of the collection for searching; recovers space. Causes collection to be taken offline, preventing searches and indexing. repair: deprecated. Does nothing.Required; see Usagelist
categoriesUsed only for creating a collection: yes: this collection includes support for categories. no: this collection does not support categories.See Usageno
collectionA collection name. The name can include spaces.See Usage
engineThe search engine for the collection: solr: the Apache Lucene open source search engine verity: the Verity search engine. For the create and map actions, the default is verity. For the list action, the default is to list all collections, Verity and Solr. For all other actions ColdFusion determines the collection type.Optionalverity
languageFor a list of options, see Usage. For languages other than English, Verity requires the appropriate (European or Asian) Verity Locales language pack.See UsageEnglish
nameName for the query results returned by the list and categorylist actions.See Usage
pathAbsolute path to a collection. To map an existing collection, specify a fully qualified path to the collection (not including the collection name); for example, "C:\MyCollections\".See Usage

Usage

With this tag you can
Create Solr or Verity collections.
Administer Solr or Verity collections created by this tag or the ColdFusion Administrator.
Administer Verity collections that were created by a Verity application.
The following table shows the dependence relationships among this tag’s attribute values:
This attribute is required, optional, or unnecessary (blank):
For this action attribute value:
  list
create
map
optimize
repair
delete
category list
collection
 
Required
Required
Required
Required
Required
Required
path
 
Required
Required
 
 
 
 
language
 
Optional
Optional
 
 
 
 
name
Required
 
 
 
 
 
Required
categories
 
 
 
 
 
 
 

The following examples show the structures returned by the categorylist action:
CATEGORIES
blue
10
green
3
magenta
3
purple
2
CATEGORYTREES
a/
10
a/b
10
a/b/c
10
a/b/c/subdir
3

The list action returns the following information in a result set that contains one row per collection:
Column
Contents
CATEGORIES
yes: the collection has category support enabled.
no: the collection does not have category support enabled.

CHARSET
The character set of the collection.
CREATED
The date and time that the collection was created.
DOCCOUNT
The number of documents in this collection.
EXTERNAL
yes: the collection is external.
no: the collection is not external.
not found: the collection is registered but is not available in the defined path.

LANGUAGE
The locale setting of the collection.
This information is not available for K2Server collections.
LASTMODIFIED
The date and time that the collection was last changed.
MAPPED
Obsolete.
NAME
The name of the collection.
ONLINE
Obsolete.
PATH
Absolute path to the collection.
REGISTERED
Obsolete.
SIZE
The size of the collection, expressed in kilobytes.

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> The code determines whether a Verity collection exists as Verity is the default engine. You may also specify engine="verity" in the code.
To determine whether a Solr collection exists, you must specifically add the attribute engine and provide the value as solr. For example,
<cfcollection action="list" name="myCollections" engine="solr">
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:
Brazilian
cjk (Chinese, Japanese, Korean)
French
Russian
Czech
Dutch
German
Thai
Chinese
English
Greek
 

For Verity collections, the language attribute of this tag supports the following options:
Asian Language Pack
Japanese
Korean
Chinese
Traditional Chinese
Multilanguage Language Pac
Unicode
 
 
 
Western European Language Pack
Bokmal
Finnish
Italian
Spanish
Danish
French
Nynorsk
Swedish
Dutch
German
Portuguese
 
Eastern European/Middle Eastern Language Pack
Arabic
Greek
Polish
Turkish
Bulgarian
Hebrew
Russian
 
Czech
Hungarian
Russian2
 

The default location for all collections is as follows:
Server configuration:
Windows: C:\ColdFusion9\verity\collections
UNIX system: /opt/coldfusion9/verity/collections
J2EE configuration: webapp_root/WEB-INF/cfusion/verity/collections

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> 
 
<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>