Does any know how to sort by key from the results of a <cfsearch>? I'm
using Verity.
I found a way by creating a list from the returned keys, then
assigning them to an array, then query the original data and matching
it to the returned keys, then using a custom tag by Nate Weiss to sort
the new query. It sounds as if it would work perfectly; however, I've
run into a few issues. Here's what I have got thus far:
--- start code ---
<CFIF ParameterExists(FORM.topic)>
<CFSEARCH COLLECTION="myCollection"
NAME="getTopics"
CRITERIA="#LCase(FORM.topic)#">
<CFSET KeyList = ValueList(getTopics.key)>
<CFSET application.keyArray = ListToArray(KeyList)>
</CFIF>
<!--- if no results are returned, do not do the additional query --->
<!--- no files found for specified criteria? --->
<CFIF getTopics.RecordCount is 0>
<CENTER>No files found for
<CFOUTPUT>"#FORM.topic#"</CFOUTPUT>
</CENTER>
<CFELSE>
<!--- run a query to pull the information about the records
that were returned as "matches" on the verity search --->
<CFQUERY NAME="unsortedResults" DATASOURCE="#APPLICATION.dataSource#">
SELECT speaker_id
FROM topic
WHERE speaker_id IN (#application.keyArray#)
</CFQUERY>
<!--- add score variable to query --->
<CFSET temp = QueryAddColumn(unsortedResults, "Key",
application.keyArray)>
<!--- sort the query based on score --->
<CFIF Find("0",KeyList)>
<CF_QUERYSORT QUERY="unsortedResults"
SORTCOLUMN="Key"
SORTORDER="Desc"
SORTTYPE="Numeric"
SORTEDQUERY="results">
</CFIF>
</CFIF>
<ul>
<cfoutput query="getTopics">
<li><a
href="test_search_details.cfm?speakerID=#key#">#getTopics.title#</a></li>
</cfoutput>
</ul>
--- end code ---
Any help or direction would be much appreciated.
Thanks.
Dylan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:285420
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4