navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

need help with filtering search results

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> need help with filtering search results
Page: [1]
 
cswolf

 

Posts: 50
Joined: 11/9/2005
Status: offline

 
need help with filtering search results - 8/19/2008 9:28:20   
I have a catalog set up with the MS Indexing Service that I am connecting to and searching it for content - no database involved here. The catalog indexes only two types of files - PDF's and WMV's. The search works perfectly right now as is, however it has now been asked of me to create an option where the user could pick to view results showing both file types (the default, which it does now), ONLY PDF's, or ONLY WMV's.

I figured that having some radio buttons for the selection of PDF or WMV would work, but how can I get the results to only show one or the other if the corresponding radio box is checked? I have worked on this somewhat with no success, mainly because I think I am making it harder than it needs to be.

I have successfully used the FSO in the past to get file extensions and I probably need to do so again here. I'm just having trouble getting started.

Any help would be appreciated, and I can supply code upon request. Thanks!
cswolf

 

Posts: 50
Joined: 11/9/2005
Status: offline

 
RE: need help with filtering search results - 8/27/2008 9:04:12   
OK, so I've had a bit of success after I posted my original request for help. It is partially working now, but not completely. I am getting some bizarre results, and so now I wondered if anyone could help me out with figuring this thing out. I will post my code at the end of the message. But first, here are the bizarre results:

When doing a default search for both file types together, it works perfectly.

When selecting the radio button to show PDF files in the results only, it begins to get weird. The results do only show PDF files (which it is supposed to), but where a WMV would have been in the list is a blank space. So in other words, it is still making the <ul></ul> tags but with nothing in between them. Then, to make things even more bizarre, the next record that should display (which would be a PDF file) is completely missing. After that, it displays everything just fine.

When selecting the radio button to show WMV files in the results only, it gets even worse. The results will show blank <ul></ul> tags again, then display some correct results, then more blank <ul></ul> tags, and then the following error message:

"ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/training/search.asp, line 232"

I never get that error if you search for only PDF's in the results. The code is basically the same for all three conditions, so I am dumbfounded as what is happening here.

Anyway, here is my code:

<form action="search.asp" method="get">
	<input name="query" type="text" %>" />
	<input type="submit" value="Search" /><br />
    <span class="search_text">Advanced Search:</span><br />
    <input name="pdf_wmv" type="radio" value="pdf" />show only PDF's in search results
    <input name="pdf_wmv" type="radio" value="wmv" />show only videos in search results
</form>

<%
Dim strQuery   ' The text of our query
Dim objQuery   ' The index server query object
Dim rstResults ' A recordset of results returned from I.S.
Dim objField   ' Field object for loop

' Retreive the query from the querystring
strQuery = Request.QueryString("query")

' If the query isn't blank them proceed
If strQuery <> "" Then
	' Create our index server object
	Set objQuery = Server.CreateObject("IXSSO.Query")

	' Set it's properties
	With objQuery
		.Catalog    = "euniversity"  ' Catalog to query
		.MaxRecords = 99           ' Max # of records to return
		.SortBy     = "rank [d]"
		.Columns    = "filename, path, vpath, size, write, " _
			& "characterization, DocTitle, DocAuthor, " _
			& "DocKeywords, rank, hitcount"

		' Build our Query: Hide admin page and FPSE pages
		strQuery = "(" & strQuery & ")" _
			& " AND NOT #filename = *admin*" _
			& " AND NOT #path *\_vti_*"

		' Uncomment to only look for files modified last 5 days
		'strQuery = strQuery & " AND @write > -5d"

		.Query = strQuery  ' Query text
	End With

	' Get a recordset of our results back from Index Server
	Set rstResults = objQuery.CreateRecordset("nonsequential")

	' Get rid of our Query object
	Set objQuery = Nothing

	' Check for no records
	If Not rstResults.EOF Then
		' Print out # of results
		Response.Write "<p><strong>"
		Response.Write rstResults.RecordCount
		Response.Write "</strong> results found:</p>"

		' Loop through results		
		Do While Not rstResults.EOF
			' Loop through Fields
			' Pretty is as pretty does... good enough:
			%>
			<div id="search">
            
            <!-- 
            Here I am going to dynamically check the file extension of the search results to determine which icon (either PDF or WMV) appears in the search list.  I am using the File System Object to do this
           
            -->
            <%
			Set fs=Server.CreateObject("Scripting.FileSystemObject")
			%>
            <ul>
           
		   <% If Request.QueryString("pdf_wmv") = "" Then %>

            <!-- Here the fso looks at the file extension of the 'path' variable from the rstResults recordset -->
            
			<% If fs.GetExtensionName(rstResults.Fields("path")) = "pdf" Then %>
            
            <!-- If the file extension is pdf, then it will display the pdf icon which is defined by the #pdf CSS class -->
            
				<li id="pdf"><strong><a href="<%= PathToVpath(rstResults.Fields("path")) %>"><%= PathToVpath(rstResults.Fields("doctitle")) %></a></strong></li>
                
                <!-- Otherwise, if the file extension is NOT pdf, then it will display the WMV icon which is defined by the #wmv CSS class -->
                
			<% Else %>
				<li id="wmv"><strong><a href="<%= PathToVpath(rstResults.Fields("path")) %>"><%= rstResults.Fields("doctitle") %></a></strong></li><br />
			<% End If %>
            
            <!-- If the record contains a document author, then display the author's name, size of file, and description -->
            
            <% If rstResults.Fields("docauthor") <> "" Then %>
            <div id="search_info">
			   <em><b>Trainer:</b></em> <%= rstResults.Fields("docauthor") %><br />
			   <em><b>Size:</b></em> <%= rstResults.Fields("size") %> bytes<br />
			   <em><b>Description:</b></em> <%= rstResults.Fields("characterization") %><br />
            </div>
            
            <!-- If no document author is found, just display the description -->
            
            <% Else %>
            <div id="search_info">
			   <em><b>Description:</b></em> <%= rstResults.Fields("characterization") %><br />
            </div>
            <% End If %>

			<% End If %>

			<% If Request.QueryString("pdf_wmv") = "pdf" Then %>
				<% If fs.GetExtensionName(rstResults.Fields("path")) = "pdf" Then %>
            
            <!-- If the file extension is pdf, then it will display the pdf icon which is defined by the #pdf CSS class -->
            
				<li id="pdf"><strong><a href="<%= PathToVpath(rstResults.Fields("path")) %>"><%= PathToVpath(rstResults.Fields("doctitle")) %></a></strong></li>

				            <!-- If the record contains a document author, then display the author's name, size of file, and description -->
							
							<% If rstResults.Fields("docauthor") <> "" Then %>
								<div id="search_info">
								   <em><b>Trainer:</b></em> <%= rstResults.Fields("docauthor") %><br />
								   <em><b>Size:</b></em> <%= rstResults.Fields("size") %> bytes<br />
								   <em><b>Description:</b></em> <%= rstResults.Fields("characterization") %><br />
								</div>
                                
                                <!-- If no document author is found, just display the description -->
                                
								<% Else %>
								<div id="search_info">
								   <em><b>Description:</b></em> <%= rstResults.Fields("characterization") %><br />
								</div>
							<% End If %>
                           
									
                <!-- Otherwise, if the file extension is NOT pdf, then it will just move to the next record -->
                
			<% Else
				
					rstResults.MoveNext 
					
			 End If
			 %>
			<% End If %>

			<% If Request.QueryString("pdf_wmv") = "wmv" Then %>
				<% If fs.GetExtensionName(rstResults.Fields("path")) = "wmv" Then %>
            
            <!-- If the file extension is wmv, then it will display the wmv icon which is defined by the #wmv CSS class -->
            
				<li id="wmv"><strong><a href="<%= PathToVpath(rstResults.Fields("path")) %>"><%= PathToVpath(rstResults.Fields("doctitle")) %></a></strong></li>

				           <!-- If the record contains a document author, then display the author's name, size of file, and description -->
                           
                            <% If rstResults.Fields("docauthor") <> "" Then %>
								<div id="search_info">
								   <em><b>Trainer:</b></em> <%= rstResults.Fields("docauthor") %><br />
								   <em><b>Size:</b></em> <%= rstResults.Fields("size") %> bytes<br />
								   <em><b>Description:</b></em> <%= rstResults.Fields("characterization") %><br />
								</div>
                                
                                <!-- If no document author is found, just display the description -->
                                
								<% Else %>
								<div id="search_info">
								   <em><b>Description:</b></em> <%= rstResults.Fields("characterization") %><br />
								</div>
							<% End If %>
									
                <!-- Otherwise, if the file extension is NOT wmv, then it will skip it and moved to the next record -->
                
			<% Else
				
					rstResults.MoveNext 
					
			 End If
			 %>
			<% End If %>

			</ul>


            </div>
			<%

			' This is line 232 where the error is being reported when using the WMV radio button.  Move to next result
			rstResults.MoveNext
		Loop

		rstResults.MoveFirst
		Response.Write "<pre>"
		'Response.Write rstResults.GetString()
		Response.Write "</pre>"
		
	Else

		' Print out # of results
		Response.Write "<p><strong>"
		Response.Write rstResults.RecordCount
		Response.Write "</strong> results found:</p>"
		
		Response.Write "Sorry. No results found."
	
	End If

	' Kill our recordset object	
	Set rstResults = Nothing
End If
%>

<%
Function PathToVpath(strPath)
	Const strWebRoot = "c:\inetpub\wwwroot\"

	Dim strTemp
	
	strTemp = strPath
	
	strTemp = Replace(strTemp, strWebRoot, "\")
	strTemp = Replace(strTemp, "\", "/")

	PathToVpath = strTemp
End Function
%>

(in reply to cswolf)
cswolf

 

Posts: 50
Joined: 11/9/2005
Status: offline

 
RE: need help with filtering search results - 8/28/2008 12:02:12   
Nevermind...I was actually able to solve the problem myself and everything works perfectly right now. Thanks.

(in reply to cswolf)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> need help with filtering search results
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts