Using K2 Server

You configure K2 Server to work with ColdFusion with the following steps:

  1. Edit the k2server.ini file to specify the alias collection names you want to expose to K2 Server. (See "Editing the k2server.ini file".)
  2. Start K2 Server by running the k2server executable. (See "Starting K2 Server".)
  3. Specify hostname and port information for K2 Server. (See "Specifying K2 Server parameters in the ColdFusion Administrator".)

Editing the k2server.ini file

To enable a collection for searching using K2 Server, you must first configure the k2server.ini file. This file is located in the cf_root\lib\ directory in Windows, and in the cf_root/lib/ directory in UNIX.

In these pathnames, cf_root refers to the ColdFusion root directory. In Windows, this is typically C:\CFusionMX; in UNIX, this is typically /opt/coldfusionmx.

The k2server.ini file consists of several parameters that typically remain unchanged. You must verify or make minor edits to settings in the portNo, vdkHome, and Coll-n sections.

To edit the k2server.ini file:

  1. Open the k2server.ini file in your text editor.

    Tip:   Use your text editor's search function to locate the appropriate code. For example, to locate the settings for the port number, as described in the next step of this procedure, search for portNo=.

    Note:   If you did not install ColdFusion into the default directory, edit the paths in this procedure to reflect the appropriate directories.

  2. In the code for portNo=, verify that the value matches the value for the K2 Server port. The default value is 9901:
    ##portNo: TCP port number for client connections.
    portNo=9901
    
  3. (Required only if you run K2 Server as a Windows service) In the code for vdkHome=, verify that the value matches the location of the Verity common directory. This is the cf_root\lib\common directory in Windows, and is the cf_root/lib/common directory in UNIX.
    ## vdkHome: directory containing Verity resources (common directory) 
      - need it running as an NT service
    ## vdkHome=c:/cfusionmx/lib/common
    

    Note:   If you run K2 Server as a Windows NT service, you must remove the pound signs (##) in the highlighted line above to uncomment the code. If the line remains as a comment, K2 Server will not execute correctly.

  4. In the code for [Coll-0], specify in the collPath parameter the directory of a collection that K2 Server will search:
    [Coll-0]
    collPath=c:\cfusionmx\verity\collections\test_01\file
    collAlias=test_01_file
    

    The collPath value must point to an existing Verity collection; the k2server executable cannot be used to create a collection.

    Note:   The final subdirectory for your collPath might differ, based on whether it is an external collection (that is, a native Verity tool created it) or ColdFusion created it. If ColdFusion created the collection, there are file and custom subdirectories; these subdirectories are not present in external collections. For more information, see "Collection structure and ColdFusion".

  5. In the next line, specify a collection alias in the collAlias parameter:
    [Coll-0]
    collPath=c:\cfusionmx\verity\collections\test_01\file
    collAlias=test_01_file
    

    You use this value to reference the collection in CFML.

    Note:   Collection alias values must be unique. They must be different from any collection names managed by ColdFusion.

    The following CFML code performs a K2 mode search on the test_01_file collection:

    <cfsearch 
      collection="test_01_file"
      name="getData"
      criteria="#form.criteria#">
    

    Note:   To search multiple collections, use a comma-delimited list. For example, use collection="test_01_file,test_02_file" in your cfsearch tag. Within a single cfsearch tag, the collections must be either all K2 Server-registered or all ColdFusion-registered; you cannot use one cfsearch tag to search a K2 Server-registered collection and a ColdFusion-registered collection.

    In the following example, the collPath value points to a collection for the ColdFusion online documentation:

    [Coll-1]
    collPath=c:\cfusionmx\verity\collections\cfdocumentation\custom
    collAlias=cfdoc_custom
    topicSet=
    knowledgeBase=
    onLine=2
    
  6. (Optional) Create a Coll-n section for other collections that you want to search with K2 Server. For each entry, increment the value n by one. The first collection is number 0, not number 1, as in the following example:
    [Coll-2]
    collPath=C:\cfusionmx\Verity\Collections\bbb\file
    collAlias=bbb_file
    
  7. Stop and restart K2 Server for changes in the k2server.ini file to take effect. For more information, see "Stopping K2 Server".

For more information about k2server.ini parameters, see "The k2server.ini parameter reference".

Starting K2 Server

You start K2 Server from the command line in UNIX or Windows. In UNIX, you run the startk2server script; in Windows, you run the startk2server.bat file. These files are located in the cf_root\lib\ directory in Windows, and in the cf_root/lib/ directory in UNIX.

In Windows, you can start K2 Server as a service by entering the following command in the cf_root\lib\ directory:

k2server -ntservice 1 -inifile k2server.ini

Note:   Macromedia does not recommend running K2 Server as a Windows service. You must stop the service before you modify or delete collections registered with K2 Server. You must then remember to restart the service. You must also verify that the vdkHome information in your k2server.ini file is uncommented-that is, it has no leading pound (#) signs-and points to the correct location of the common directory.

Specifying K2 Server parameters in the ColdFusion Administrator

You use the Verity K2 Server page in the ColdFusion Administrator to specify the hostname and port number for the K2 Server you want to use, as the following figure shows:

The figure shows the Verity K2 Server page in the ColdFusion Administrator.

Make sure that you started K2 Server on the host you specify in the Verity Server hostname field. Also, the port number you enter must match the port number you specify in the k2server.ini file.

Comments