Adding an indexed Search to your site (Part 1)

Go to part two of this tutorial4

Verity Search

If your site has a lot of content, text files, or even Excel spreadsheets, you may want to consider using the Verity Search Collection in ColdFusion. Verity Collections allow you to index your site and create a ?map? if you will, of your files. Even the contents of your doc files, PDF?s, and spreadsheets. What will really amaze you is how little it takes to set up and create.

First of all you need access to the CF administrator, or you need to have the server administrator configure the server to index your site. If you run your own server then this will be a snap.

==========================
PART ONE - Configuring the server
==========================

Open the ColdFusion administration page and log in. On the Left hand side under ?Datasources? is a link labeled ?Verity Collections? Click the link.

VERITY COLLECTIONS
This is the page you will no be on. In the first section create a NAME for your collection. This can be any name that you wish to use. I will call it ?boxcar? for now.

The PATH field is for the location you would like to store the collection file. It is not to be confused with the location of the files you want index. Leave it at the default setting unless you have reason to change it.

Next Click the button ?Create Collection?

INDEX VERITY COLLECTIONS
The field for file extensions has a few default file types already in place, however you may want to add other file types. Here is a list of files that are common that you might use. Just add the appropriate extension to the list.
ASCII Text
HTML
Lotus
Rich Text Format
Microsoft word
PDF
PowerPoint
Excel

DIRECTORY PATH is the physical location of the files on your server. IE C:\www\my_site

The RECURSIVE INDEX SUB DIRECTORY check box may be checked if you want the index to include files beneath the selected directory.

Last but not least, the RETURN URL. This is the actual path for your HTTP files.
IE. http://my_server/my_site/
It?s important to get the URL correct as this is used to create the links in your search results.

Now click Submit, your server will now index your site.

=============================
PART TWO ? Creating the search forms
=============================
Search_form.cfm
-------------------------------------
<html>
<head>
<title>
Search this site</title>
</head>

<body>

   <strong>What would you like to search for? </strong>
   <form name="form1" method="post" action="verity_search_results.cfm">
   <p>
      <input name="criteria" type="text" id="criteria">
      <input type=
"submit" name="Submit" value="Submit">
   </p>
   </form>
</body>
</html>




-------------------------------
search_results.cfm
-------------------------------
<!--- Define a search name and specify the COLLECTION name used in the CF Admin.--->
<CFSEARCH NAME="search_boxcar"
                 COLLECTION=
"boxcar"
                 CRITERIA=
"#FORM.criteria#">

<html>
  <head>
     <title>
Search Results</title>
  </head>

<body>
<h3>
Your search results </h3>

<!--- Output search results complete with score --->
<CFOUTPUT QUERY="search_boxcar">
    <a href="#URL#">#Title#</a><br>
    Score: #Score#<p>
</CFOUTPUT>

</body>
</html>


The key here is the CFSEARCH tag. It is the easiest search ever and no SQL involved. However, if you want to add an SQL statement you can do more with it. Like search you database or your query.

That?s all there is to it.

Go to part two of this tutorial4



All ColdFusion Tutorials By Author: Mark Aplet
  • Adding an indexed Search to your site (Part 1)
    It is very easy to set up and create a professional search function much like a real search engine. Use Verity Collections and the tag to create fast search forms for your web sites.
    Author: Mark Aplet
    Views: 27,821
    Posted Date: Saturday, February 1, 2003
  • Adding an indexed Search to your site (Part 2)
    The long overdue part two of adding a verity search function. This part demonstrates how to index the information in your database so that it becomes usefull too.
    Author: Mark Aplet
    Views: 17,845
    Posted Date: Monday, May 5, 2003
  • Banning the spam
    Internet spam is on the rise, and more importantly spammers are targeting your sites comment forms. They are looking for the trackback urls to fool search engines into ranking their website higher in the search results. When this started to happen to me, I wanted to sent out emails to the offenders demanding that they stop. Unfortunatly the spam is being generated by bots and programs not some pimple faced kid behind a keyboard. Banning IP addresses is not enough and rarely works since intelligent spammers hide their true identity anyway. Next approach... Banning Keywords used by the offending sites. Thats where this tutorial comes in.
    Author: Mark Aplet
    Views: 6,354
    Posted Date: Wednesday, March 15, 2006
  • Changing site color scheme
    Add some personalization to your pages by letting the user pick their own color scheme. It's really quite simple and the benifits are awsome. This tutorial shows you how to set up your pages to use a dynamicly included scheme. It will also show you how to create all the pages neccessary to administer the color schemes.
    Author: Mark Aplet
    Views: 16,897
    Posted Date: Friday, November 29, 2002
  • Color Picker
    Sometimes, you want to be able to change the color of something on your page. Be it one item, or every item on the page. Using this simple color picker, you can create admin areas that can allow you or your visitors to pick their own colors and the value is automatically inserted into a text field.
    Author: Mark Aplet
    Views: 10,862
    Posted Date: Saturday, July 12, 2003
  • Dynamic Sorting with CFSWITCH
    Quickly and easily sort and order records in your database using a cfswitch in your query. Great technique for admin areas of your site, or just allowing visitors to sort the fields they want.
    Author: Mark Aplet
    Views: 13,845
    Posted Date: Sunday, August 3, 2003
  • Improving Application Performance
    One thing I am always trying to do is speed up my applications. As my site grows in size and complexity I find that I spend a fair amount of time re-coding pages because of a new technique I just learned. I wish I had learned about these techniques long before, and thereby allowing me to create more effective code. In this tutorial I'll try to explain some problem areas that I have identified, and some of the things you can do to improve performance.
    Author: Mark Aplet
    Views: 10,609
    Posted Date: Monday, January 12, 2004
  • Improving Application Performance (Part 2)
    Not all queries can be saved as an application variable. For Queries that do not meet the checkpoints in my previous tutorial there is another way to improve performance. Query Caching is another way to save data and eliminate unnecessary queries. This is for queries that are more dynamic in nature.
    Author: Mark Aplet
    Views: 8,180
    Posted Date: Monday, January 12, 2004
  • Slighty better search
    Someone on the forum posed a question a short while ago asking how to create a more advanced search function using a + symbol as a separator. So I created this advanced search function. This search function is just slightly better than a normal search as it adds the ability to separate two keywords with a + symbol. Lets start with the search form.
    Author: Mark Aplet
    Views: 11,509
    Posted Date: Thursday, December 4, 2003