> I was wondering if anyone has a solution for creating a 
> verity search that needs to index BOTH a database and 
> subdirectories of html files?

This is actually pretty easy. You have a couple of options.

1. Simply search across multiple collections in your CFSEARCH tag - you can
specify a comma-delimited list of collections.

2. Index both files and database queries into a single collection. There's
nothing special you have to do in this regard; just use the same collection
attribute within your CFINDEX tags. For some unexplainable reason, I've had
better success indexing database content, then files. Here's an example I
threw together a while back, which mixes two database queries and static
files within the same collection:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
        <title>My Indexing Page</title>
</head>

<body>

<cfquery name="qUsers" datasource="...">
        SELECT  mykey = 'users:' + userid, 
                        username, 
                        fname, 
                        lname
        FROM            users
</cfquery>

<cfindex action="update"
        type="CUSTOM" 
        key="mykey" 
        title="username"
        body="fname, lname" 
        collection="mycollection">
        
<cfquery name="qItems" datasource="...">
        SELECT  mykey = 'items:' + itemid,
                        itemname,
                        itemdesc
        FROM            items
</cfquery>      

<cfindex action="update"
        type="CUSTOM" 
        key="mykey" 
        title="itemname"
        body="itemdesc" 
        collection="mycollection">
        
<cfindex action="update"
        type="PATH"
        key="c:\inetpub\wwwroot\filelibrary\" 
        urlpath="http://localhost/filelibrary/";
        collection="mycollection" 
        extensions="">

</body>
</html>

In either case, the slightly difficult part is writing code to display the
mixed output - some from files, some from databases. It essentially boils
down to a bunch of conditions for displaying each record. Here's an example
of that:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
        <title>Search Results</title>
</head>

<body>

<cfsearch collection="mycollection,myothercollection"
        criteria="#Form.search#"
        name="qSearchResults">
        
<cfoutput query="qSearchResults">
        <cfif len(trim(url))> <!--- it's a file --->
                <a href="#url#">#title#</a>
        <cfelse> <!--- it's from the database --->
                <cfif mykey contains "items">
                        <a href="showitem.cfm?id=#key#">#title#</a><br>
                <cfelseif mykey contains "users">
                        <a href="showuser.cfm?id=#key#">#title#</a><br>
                </cfif>
        </cfif>
</cfoutput>

</body>
</html>

Enjoy!

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to