<cfparam name="form.startrow" default="1">
<CFSET SearchCollection = "LSNJLAWSearch">
<CFSET UseURLPath = "YES">
<cfparam name="form.maxrows" default="10">
...
<CFSEARCH
name = "GetResults"
collection = "#SearchCollection#"
criteria = "#Form.Criteria#"
maxRows = "#Evaluate(Form.MaxRows + 1)#"
startRow = "#Form.StartRow#"
>
...
<CFOUTPUT query="GetResults" maxRows="#Form.MaxRows#">
<TR bgcolor="#IIf(CurrentRow Mod 2, DE('ffffff'), DE('cccccc'))#">
<!--- current row information --->
<TD>#Evaluate(Form.StartRow + CurrentRow - 1)#</TD>
<!--- score --->
<TD>#Score# </TD>
<CFIF UseURLPath>
<!--- URL parameter from cfsearch contains URL path info --->
<CFSET href = Replace(URL, " ", "%20", "ALL")>
<CFELSE>
<!--- ... else use OpenFile to return the file --->
<CFSET href = "SearchOpenFile.cfm?serverFilePath=#URLEncodedFormat(Key)#">
</CFIF>
<!--- if the user is coming from the index page, send them to the first result, and pass the number of search results in the URL. if they are coming from the search page, check which radio button is selected and proceed accordingly. --->
<cfparam name="cgi.http_referer" default="">
<cfparam name="form.full" default="yes">
<cfif form.full EQ "no">
<cflocation url="#href#?results=#GetResults.RecordCount#&criteria=#form.criteria#">
</cfif>
<!--- title for HTML files --->
<TD><a href="#href#">#Title#</a> </TD>
</TR>
</CFOUTPUT>
...
<!--- CFSEARCH tried to retrieve one more file than the number specified in the
Form.MaxRows parameter. If number of retrieved files is greater than MaxRows
we know that there is at least one file left. The following form contains only
one button which reloads this template with the new StartRow parameter. --->
<CFIF GetResults.RecordCount gt Form.MaxRows>
<FORM action="SearchResult2.cfm" method="post">
<CFOUTPUT>
<INPUT type="hidden" name="Criteria" value="#Replace(Form.Criteria, """", "'", "ALL")#">
<INPUT type="hidden" name="MaxRows" value="#Form.MaxRows#">
<INPUT type="hidden" name="StartRow" value="#Evaluate(Form.StartRow + Form.MaxRows)#">
<INPUT type="submit" value=" More ... ">
</CFOUTPUT>
</FORM>
</CFIF>
Yes I did use the wizard that comes with my IDE. Please note that I am using the Cold Fusion 4.0 Verity Wizard at my workstation to create this because I do not have MX Cold Fusion studio at my workstation although we have MX on our server now.
Here is the script for "VSearchResult.cfm"
<CFSET SearchDirectory = "C:\directorypathhere">
<CFSET SearchCollection = "myName">
<CFSET UseURLPath = "YES">
<!--- retrieve requested files --->
<CFSEARCH
name = "GetResults"
collection = "#SearchCollection#"
criteria = "#Form.Criteria#"
maxRows = "#Evaluate(Form.MaxRows + 1)#"
startRow = "#Form.StartRow#"
>
<HTML><HEAD>
<TITLE>mySearch - Search Results</TITLE>
</HEAD><BODY bgcolor="#FFFFFF">
<FONT size="+1">mySearch</FONT> <BR>
<FONT size="+2"><B>Search Results</B></FONT>
<P>
<!--- no files found for specified criteria? --->
<CFIF GetResults.RecordCount is 0>
<B>No files found for specified criteria</B>
<!--- ... else at least one file found --->
<CFELSE>
<TABLE cellspacing=0 cellpadding=2>
<!--- table header --->
<TR bgcolor="cccccc">
<TD><B>No</B></TD>
<TD><B>Score</B></TD>
<TD><B>File</B></TD>
<TD><B>Title</B></TD>
</TR>
<CFOUTPUT query="GetResults" maxRows="#Form.MaxRows#">
<TR bgcolor="#IIf(CurrentRow Mod 2, DE('FFFFFF'), DE('FFFFCF'))#">
<!--- current row information --->
<TD>#Evaluate(Form.StartRow + CurrentRow - 1)#</TD>
<!--- score --->
<TD>#Score# </TD>
<!--- file name with the link returning the file --->
<TD>
<CFIF UseURLPath> <!--- URL parameter from cfsearch contains URL path info --->
<CFSET href = Replace(URL, " ", "%20", "ALL")>
<CFELSE> <!--- ... else use OpenFile to return the file --->
<CFSET href = "MyApplication_VOpenFile.cfm?serverFilePath=#URLEncodedFormat(Key)#">
</CFIF>
<A href="#href#">#GetFileFromPath(Key)#</A>
</TD>
<!--- title for HTML files --->
<TD>#Title# </TD>
</TR>
</CFOUTPUT>
</TABLE>
<!--- CFSEARCH tried to retrieve one more file than the number specified in the
Form.MaxRows parameter. If number of retrieved files is greater than MaxRows
we know that there is at least one file left. The following form contains only
one button which reloads this template with the new StartRow parameter. --->
<CFIF GetResults.RecordCount gt Form.MaxRows>
<FORM action="mySearch_VSearchResult.cfm" method="post">
<CFOUTPUT>
<INPUT type="hidden" name="Criteria" value="#Replace(Form.Criteria, """", "'", "ALL")#">
<INPUT type="hidden" name="MaxRows" value="#Form.MaxRows#">
<INPUT type="hidden" name="StartRow" value="#Evaluate(Form.StartRow + Form.MaxRows)#">
<INPUT type="submit" value=" More ... ">
</CFOUTPUT>
</FORM>
</CFIF>
</CFIF>
</BODY></HTML>
Thanks for any help you can provide!
It looks like you are both using more or less the same wizard driven code. The wizard is a great place to start, but it really needs some tweaking...
Check out: "#Evaluate(Form.MaxRows + 1)#" - this will always be 11, right? So, there is the reason why you are only getting 11 records in your search results regardless of how many records you have in the collection.
What I would recommend is removing startrow and maxrows from the CFSEARCH. Use them in the CFOUTPUT to just output the records you are looking for. The extra overhead of the Verity records that you are not displaying really is negligable in most cases. When you move into K2 mode searches and using caching, you actually will get better performance because the query will not have to rerun when doing next 'n' page stepping. If you change the startrow and maxrow values, K2 has to rerun the query, and can't take advantage of cached queries.
Since VDK mode basically opens a collection, searches it, then closes it, passes the resultset to CF which then filters it via the CFSEARCH parameters, and then hands that back as the result set, there is no huge performance gain by telling VDK to only return "these" 10 records vs. the entire record set. VDK mode is not a relational database that has the tables loaded into memory. K2 mode works more like a relational database in that respect. That is one of the many reasons that K2 is so much faster.
For CF4.0, you are out of luck and stuck with VDK mode, however, since you are using CFMX in production, you should look at using K2 to speed everything up.
Hope this helps,
John M. Salonich II
Team Macromedia Volunteer for ColdFusion
Sr. Web Developer
UMass Medical School