Implementing a Search Engine ColdFusion Help

One of the most common features of today’s large Web sites is a search engine.
Through a search engine, users can search for specific documents within a large number of documents on a Web site, effectively finding the proverbial needle in the haystack. ColdFusion Server leverages the power of Verity’sSearch 97 indexing engine to provide
efficient, easy-to-use search capabilities integrated into the ColdFusion environment. With this facility, you can achieve many results, including:

• Searching HTML documents on a Web site
• Searching the results of queries executed by tags such as CFQUERY and CFPOP
• Searching collections of binary documents such as Microsoft Word documents or Adobe Acrobat files
In this chapter, you will look at the three steps required to create a searchable set of data: defining a collection, indexing the data, and searching the index.

Creating Collettions

At the heart of any search system using ColdFusion and Verity is the collection. A collection is a set of information that can be indexed and searched as a set. A collection can be used to group types of information such as the following:
• All the HTML files in a Web site
• Files in specific directories to create subject or section-specific search capabilities
• Sets of binary files including the most popular word processor and spreadsheet formats
• Data returned by anystandard ColdFusion query

To implement any search engine in ColdFusion, you first need to create a collection. You can do this in two ways: through the ColdFusion Administrator or by using the CFCOLLECTION tag.

Creating Collections by Using the ColdFusion administrator

The Verity page of the ColdFusion Administrator, shown ill Figure 29.1, is where collections are created and managed. This page presents a list of existing collections (the ColdFusion documentation will appear as a default collection if you  it when you installed ColdFusion Server) followed by a form for creating new collections.

Using this form, you have two options:
• Creating a new collection
• Mapping an existing Verity collection into the ColdFusion environment

This latter option is important because Verity collections can be created, using standard Verity tools and there needs to be a way to make ColdFusion aware of these collections so that they can be used in templates.

To create a new collection with ths.Coldfusion Administrator, you need to provide the following information:

Name All collections are named so that they can be accessed later in ColdFusion templates. .
Path The location where files related to the collection will be stored (it is best to accept the default-the Veri ty\Co 11ecti ons subdirectory of your ColdFusion directory).
Language By default, all collections are for English-language data; if you have bought the International Language Search Pack (available from Allaire), then you will be able to select from other European languages for a collection, including French, German, Italian, Portuguese, and Spanish.

After you provide this information, make sure that Create a New Collection is selected .and click the Apply button. The new collection will appear at the top of the Verity Collections page,

After a collection is created, several administrative tools are then available, as outlined in the following list:

Index Creates an index of data for the collection. This process is outlined in the
Indexing Data” section of this chapter.
Repair Repairs a corrupted cqllection. This is a non-destructive process that may take some time to complete for larger collections.
Optimize Optimizes a collection. As the amount of data being indexed in a collection grows, it is a good idea to optimize it so that searches can be as efficient as possible.
Purge Purges all indexes from a collection. This effectively empties the collection of all indexed data and returns it to the state it was in when it was created.
Delete Deletes a collection:’ Once deleted, the collection as well as its indexes are inaccessible and the collection will need to be re-created to be used again.

The last four options are simple to use:
1. Select the desired collection.
2. Click the relevant button below the collection list.
3. Click OK in the confirmation dialog box that appears to execute the action or click

Cancel to cancel the request.
Using the Index function requires a bit more care and is discussed in the “Indexing Data” section.

Creating Collections with the CFCOLLECTION Tag

Using the CFCOLLECTIONtag, you can create collections in your ColdFusion templates without having to access the ColdFusion Administrator. This is useful for several reasons, the most notable of which is enabling content creators on your Web site to create collections and search engines without providing them access to the ColdFusion Administrator (which would be an unnecessary security risk).

The CFCOLLECTIONtag takes the following four attributes:
ACTION Indicates which action to perform. Possible actions are Create, Repat , OptimIzer, Delete, and Map.
COLLECTION TIle name of the collection to be created or worked with.
PATH The path to the directory where the collection should store its files. This is required when using ACTION=Create.
LANGUAGE The language in which to create a collection when ACTION =Create is used.
The default language value is Eng1;sh and the attribute is optional.
Using the CFCOLLECTIONtag to repair, optimize, or delete a collection is simple, requiring only the ACTIONattribute and the COLLECTIONattribute

To create a collection, though, requires at least three attributes: ACTION,COLLECTION, and PATH.For instance, to create the same collection as was created using the ColdFusion Administrator earlier in this chapter, the following tag should be used:

Posted on November 16, 2015 in Implementing a Search Engine

Share the Story

Back to Top
Share This