Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mark new documents in search results

Status
Not open for further replies.

calista

Programmer
Joined
Jan 24, 2001
Messages
545
Location
US
I have a search function that is a full text search. I index the directory the documents live in, and my search is against that collection. Is there any way, when displaying the search results, to know when a file was uploaded? I would like to mark as "New!" any documents uploaded within the past two weeks. I store that information in the database, but since my search is not against the database, I'm not sure how to retrieve that information using the search results. Any ideas?

Thanks! Calista :-X
Jedi Knight,
Champion of the Force
 
Hey Calista,

I guess you're like me and excited about the upcoming SWEP II :)

For your search results, I would just do a <cfdirectory> during your output loop and retrieve the filedate that way. You might be able to supply the filename as the filter argument and limit the results to just that filename. If not, you can just loop through the results to find that filename. It's not a real efficient solution but I don't see an easy way to do it otherwise.

If you wanted something more efficient for a high traffic site, I would just create a simple ocx in VB to retrieve the file's date and call it with the <cfobject> tag.

Hope this helps,
GJ
 
If I was going to do it.. I guess I'd change the file name on upload and make the first 8 characters the file date so today's uploads would be like

05062002myfile.txt..

Or maybe number the days of the year and then just subtract 14?

Tony
 
Well, guys, as usual, I was making this harder than it had to be. Here's what I did:

Within my CFOUTPUT for the search results, I used &quot;GetFileFromPath(#URL#)&quot; to isolate the file name, then did a query against my database using the file name as my criteria. That gave me my date, and then I did a &quot;DateCompare&quot; to determine if the document was &quot;New&quot;.

<CFOUTPUT QUERY=&quot;GetSearchInfo&quot; STARTROW=&quot;#StartRow#&quot; MAXROWS=&quot;#OnEachPage#&quot;>
<CFIF CurrentRow MOD 2 EQ 0>
<CFSET COLOR=&quot;#Application.LightColor#&quot;>
<CFELSE>
<CFSET COLOR=&quot;#Application.Lighter#&quot;>
</CFIF>
<cfset MyFileName = GetFileFromPath(#URL#)>
<cfquery name=&quot;GetMyInfo&quot;
datasource=&quot;#Application.Datasource#&quot;>
SELECT *
FROM DocumentTable
WHERE DocFileName = '#MyFileName#'
</cfquery>
<cfif #GetMyInfo.RecordCount# EQ 0>
<cfset MyDate = #OneMonthAgo#>
<cfelse>
<cfset MyDate = #GetMyInfo.DocCreateDateTime#>
</cfif>
<TABLE WIDTH=&quot;100%&quot; BORDER=&quot;1&quot; BORDERCOLOR=&quot;#Application.DarkColor#&quot;>
<TR BGCOLOR=&quot;#Color#&quot;>
<CFSET CheckMyDate = DateCompare(MyDate,TwoWeeksAgo)>
<cfif CheckMyDate EQ 1>
<td width=&quot;50&quot;><img src=&quot;../CommonFiles/Images/New1.gif&quot; alt=&quot;&quot; width=&quot;35&quot; height=&quot;17&quot; border=&quot;0&quot;></td>
<cfelse>
<td width=&quot;50&quot;><img src=&quot;../CommonFiles/Images/TransGif.gif&quot; alt=&quot;&quot; width=&quot;36&quot; height=&quot;18&quot; border=&quot;0&quot;></td>
</cfif>
<TD WIDTH=&quot;10%&quot;>#Score#</TD>
<TD COLSPAN=&quot;2&quot; WIDTH=&quot;90%&quot;><A CLASS=&quot;Normal&quot; HREF=&quot;#Application.DocLocation##URL#&quot; TARGET=&quot;_blank&quot;><STRONG>#Title#</STRONG></A></TD>
</TR>
</TABLE>
</CFOUTPUT> Calista :-X
Jedi Knight,
Champion of the Force
 
Well thanks for sharing that code since you did find your solution.
 
Tony,

I figure we should share the solution even if we eventually figure it out ourselves so others may benefit.

You posted a message a few weeks ago I now have an interest in.

Thanks! Calista :-X
Jedi Knight,
Champion of the Force
 
If you'll tell me what message it is.. I probably have the solution.. glad to help any time.. you can find me on Yahoo as &quot;webmigit&quot; or &quot;bibleclicks&quot;, on AOL as &quot;Clickthru Bible&quot;, on msn as webmigit@hotmail.com.

I rarely give up on an idea.. only if I cannot come up with, or come accross a solution and I almost always get the solution so I'll be glad to share what I know.

Tony
 
If you're using CF5, I would suggest doing the <cfsearch>, then querying the DB once, then using a query of queries to join the query result set returned by <cfsearch> to the one returned from the database. Then you'll have a single query set that has the search results and the date last modified for each file.

This will be much more efficient than going back to the database for each search result -- doing that is very costly performance-wise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top