Probably the fastest way to do this, however, would be to create a clustered index that includes data about each result set. For instance, you could create a list that indexes both sets of results without having to create any new structures.
Create a list to contain the values, then loop over each result set. Append the following data cluster to the list for each record: "score|resut_set_name|index". Sort the list then output it using evaluate on the second and third attributes of the cluster. M > -----Original Message----- > From: Mike Mertsock [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 26, 2003 11:03 AM > To: CF-Talk > Subject: Okay, how could I accomplish this? > > > >Yeah, but here's the thing. The tables hold data that can be > stuck into > >"key, title, body" columns, but the display of each column is > >different, so each collection will be displayed differently, > thus the > >"custom1" column in my cfsearch. I want to mix the results > for display > >purposes, showing scores correctly ranked when mixed, but I want to > >display the results differently. My solution was to search each > >collection, place the results into a structure of some sort, > including > >the "custom1" column that will determine how to display the > data on the > >details page, and sort them all by "score" so that output > results are > >"sorted" by "score" yet their "colum1" information will > determine how > >the data is displayed on the following page. > > > >Make sense? > > > >So *can* you do that? stick each result set into some sort of data > >structure for each query returned, then sort that structure, > ordering > >by "score", then outputting the results? > > > >For instance, collection 1 returns the following: > >Score - Title (custom1) > >97 - My New Title (1) > >67 - A Second Title (1) > >78 - The Fifth Title (1) > > > >And collection 2 returns the following: > >86 - The Title of This Document is This (2) > >76 - I'm Titling This Document Thusly (2) > >23 - A Whimsical Title To Enjoy (2) > > > >Then my output is as follows: > >97 - My New Title (1) > >86 - The Title of This Document is This (2) > >78 - The Fifth Title (1) > >76 - I'm Titling This Document Thusly (2) > >67 - A Second Title (1) > >23 - A Whimsical Title To Enjoy (2) > > > >See? Then, when you clicked the link, you'd know *which* collection > >passed you the results...then you could display it > appropriately, if it > >needs to be displayed differently (which mine does). > > Perhaps you could avoid trying to put the two queries into > one structure... > > What you want to do is *exactly* like the merge portion of > the merge sort algorithm - the problem is to take two > already-sorted data structures and combine them into a single > sorted structure. Merge sorts are known to be very fast, so > perhaps an efficient solution would be to mimic the merge > part of the merge sort algorithm. Here's the basic idea: > > list A = 1, 3, 4, 6 > list B = 2, 3, 5, 7 > merge into: 1 2 3 3 4 5 6 7 > to merge the two lists: > loop while A and B have elements remaining > --compare the first elements of A and B > --if B is less, append to final list > --else, append A's first element instead > end loop > > So to mimic this: > > Initialize two counters - counterA and counterB - to 1 -- you > begin by looking at the first record from each query > > loop while both counters are LTE their respective recordcount > --compare queryA.score[counterA] and queryB.score[counterB] > --if the score from B is GT the score from A ----output info > for B, iterate counterB --else ----output info for A, iterate > counterA end loop > > One thing to remember - you can go through all the records of > one query before the other query is finished so you need to > test for that. > > Something like that. Data structures was my favorite class in > college :-) > > Mike Mertsock > Alfred University Web Team > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm