com.sebtools Build 12 Documentation: Searcher.cfc

Searcher.cfc

Searcher.cfc helps simplify searching functionality.

Initializing

When initializing Searcher.cfc, you need to specify a file path in which to store collections as well as passing in DataMgr and the browser path to a page to handle forwarding searches (more on that later).

You can optionally specify directories and/or files to be excluded from a search.

Indexing

The first thing that you need to do in order to have Searcher work is to index one or more collections. If you want to index files, use the indexPath() method (the key argument is the file path that you want to index).

If you want to index data from a database, you need to query the database and index the query using the indexQuery() method.

Searching

To search for a term, simply call the run() method. Pass in the search string and optionally pass in a list of collections to search.

Forwarding

In order to count a selected page, Searcher must have a page that redirects the user to the desired page. The file specified in the "sendpage" argument of the init() method should have the following code (assuming Searcher.cfc is loaded into Application.Searcher).

<cfif isDefined("url.searchid") AND isDefined("url.to")>
	<cfset Application.Searcher.send(url.searchid,url.to)>
</cfif>

Extension

You can also extend Searcher.cfc for an individual site if you want to customize the way it works for a particular site. For example, you could overwrite the run() method to filter the Summary based on extra code you know to be in the site.

CFC Docs

Blog Entries