I've always thought that CFSearch was rather "quirky", to say the least.
 
Firstly there's the maxrows facility in CF 5, that when specified, will actually spit out one more row than the number input. So a cfsearch with maxrows set to 10, say, will actually return 11 records.
 
Genius!
 
I can live with this.
 
However, what I was surprised about with CFMX (6.1), is that MM have managed to fix this rather blindingly obvious error. It now spits out up to the exact number specified in Maxrows.
 
Woohoo!
 
Exactly, that is, unless you specify a different start row. In my usual fashion, I create a search engine that outputs 10 or 20 rows at a time. The first time the search is run, there's a test search to find out how many results the search produces. Then the real search for output goes something like this:
 
<cfsearch criteria="#Trim(attributes.Criteria)#" type="SIMPLE"
   maxrows="20" collection="#request.CollectionName#"
   startrow="#attributes.Startrow#" name="FullSearch">
 
so attributes.Startrow will be 1, 11, 21...
 
All well and good in CF5, but in MX, as soon as the second result set is called for, nothing comes out the other end.
It took me quite a while to figure out what's going on. I checked the macromedia knowledge base (which only takes about 4 hours to find anything), nothing. I checked the MM forums (which takes about 3 hours per search), nada.
 
So I tried the following:
 
<cfsearch criteria="*" type="SIMPLE"
 collection="#Request.CollectionName#" name="Search1">
<cfsearch criteria="*" type="SIMPLE" maxrows="10"
 collection="#Request.CollectionName#" startrow="1" name="Search2">
<cfsearch criteria="*" type="SIMPLE" maxrows="10"
 collection="#Request.CollectionName#" startrow="11" name="Search3">
<cfsearch criteria="*" type="SIMPLE" maxrows="20"
 collection="#Request.CollectionName#" startrow="11" name="Search4">
 
<cfdump var="#Search1#">
<cfdump var="#Search2#">
<cfdump var="#Search3#">
<cfdump var="#Search4#">
 
 
And here are the results:
 
Search 1: 109 records
Search 2: 10 records
Search 3: 0 records
Search 4: 10 records
 
So it turns out that Maxrows in MX isn't maxrows at all... The functionality is really Endrow.
 
Pure bloody genius on a stick!
 
Taz

Reply via email to