The ASP Page is where things get really cool. You use the values from the form to drive the objects that will query the index server.
Here's the overall process:
- Set up the server object
- Open the recordset
- Step through the recordset, using standard ADO methods
You can download the basics of the ASP page by clicking here and then follow along. Again, it's a text file from this link, but you can cut and paste it as needed for your use.
The first thing you have to do is to set up the reference to the index server object. You do that by using the server.creatobject method:
Set objQuery = Server.CreateObject("ixsso.Query")Add in the properties...
Now the objQuery object is set up and ready to be configured, prior to setting up the recordset that references it. Of course one of the fundamental things that you'll need to do is to set up the query - what you are looking for in the database. This is done from the incoming URL information - and there is a method to pull all of this from the URL and put it into the object automatically:
This will pull all of the different parameters, properties and query string information from the URL and put it where it belongs in the object. This is how the parameters set up as hidden fields in the form are translated into properties for the search.Stir in the columns...
Next, indicate which columns you'll want to return from the search. We've called out the most common, and those which will provide you with summary and URL information. There are others, but that's a subject for a future article!
In this case, we're asking for the filename, the number of hits that are occuring in the source file for the search string we've provided, the document title (between the TITLE tags in the HTML), and the summary information for the file. This will give the user the overview of what the page is about.
If you place the DESCRIPTION meta tag in your pages, the characterization will include that information. If not, the characterization will provide a look at the first portion of each page as it's shown. Index server will ignore include and scripting text in the files, so you'll generally only get "real" content.And Bake...
You're ready to query the database - simply create the recordset just as you would any ADO data source.
set rsQuery = objquery.createrecordset ("nonsequential")
Voila! You've just queried your server. No mess, no fuss. What you have now is a recordset, rsQuery, that you can use MoveNext, MovePrev, etc. methods on. You'll be able to reference each of the columns returned by the query by simply calling them out with the rsQuery object:
You even have the standard recordcount property associated with the results. rsquery.recordcount will let you know the total number of rows returned, up to the maximum value you indicated in the properties for the query.
Give it a try - just search from the tool on the left - and you can follow along in the code from the pages you've just downloaded. It's really an excellent way to search your site and use the Index Server.The Frosting...
The frosting on this cake is how you handle the output of the search results. Paging, formating the links, etc. It's all presentation, right?! Stay tuned - if enough people are interested in hearing more, I'll write up part II of this article - How to page your results, how to format your results.