Internal Search Engine question.

Now-a-days, I am working on a big site and I want to make an Internal search engine for this also.

There are 6 major categories. I wanna give a drop down box which should contains all the major categories + search in all the categories.

I know there is a Tag in CF i.e. <CFINDEX> but I don't wanna use as it doesn't give the to too many options to customize.

I donno much about it. What I am doing is.. making a Table. This table will contain: Keywords field, Description Field, the URL of the file, therefore, I can search for a specified keyword from the table. But again, there is a prob. if wanna extended search like provided by Yahoo! or Altavista.

Can anybody send/tell me any Website or tutorial where I can find information about search engines (specially doing it with Cold Fusion, if possible)?

Thanks and regards,
Rajesh
(rknewsletters@yahoo.com)
rkchopraAsked:
Who is Participating?
 
nathansConnect With a Mentor Commented:
I am giving you a start on doing this...

you will need to check the datasource and the column names to make them match yours of course.

here are some files you need
===============================
index.cfm
===============================
<cfinclude template="app_locals.cfm">

<cfswitch expression="#attributes.fuseaction#">

 

  <cfcase value="Search">
    <cfinclude template="dsp_Search.cfm">
  </cfcase>

  <cfcase value="SearchDisplay">
    <cfinclude template="act_SearchDisplay.cfm">
    <cfinclude template="dsp_SearchDisplay.cfm">
  </cfcase>

 
<!---  
  <cfcase value="">
    <cfinclude template="dsp_.cfm">
  </cfcase>
 --->



</CFswitch>

================================
search.cfm
================================

<html>
<head>
      <title></title>
</head>
<body bgcolor="ffffff">
<table align="center" border="1" bordercolor="000000" cellpadding="0" cellspacing="0"><tr><td>

<form action="index.cfm?FuseAction=SearchDisplay" method="post">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="dddddd">
      <td colspan="2">&nbsp;&nbsp;<font face="Arial" size="-1"><b>My Page</b></font></td>
</tr>
<tr>
      <td colspan="2"><br>&nbsp;&nbsp;<input type="text" name="Text" size="25" maxlength="100"><input type="submit" value=" Search ">&nbsp;&nbsp;<br><br></td>
</tr>
<tr>
      <td>&nbsp;&nbsp;<input type="radio" name="SearchType" value="Normal" checked><font face="Arial" size="-1">Normal</font></td>
      <td>&nbsp;&nbsp;<font face="Arial" size="-1">
      <select name="Category">
      <option value="Cat 1">Cat 1</option>
      <option value="Cat 2">Cat 2</option>
      <option value="Cat 3">Cat 3</option>
      <option value="Cat 4">Cat 4</option>
      <option value="Cat 5">Cat 5</option>
      <option value="Cat 6">Cat 6</option>
</select>
</font></td>
</tr>
<tr>
      <td colspan="2">&nbsp;&nbsp;<input type="radio" name="SearchType" value="Exact"><font face="Arial" size="-1">Exact Match</font></td>
</tr>
<tr>
      <td colspan="2">&nbsp;&nbsp;<input type="radio" name="SearchType" value="All"><font face="Arial" size="-1">Matches on all words (AND)</font></td>
</tr>
<tr>
      <td colspan="2">&nbsp;&nbsp;<input type="radio" name="SearchType" value="Any"><font face="Arial" size="-1">Matches on any word (OR)</font></td>
</tr>
</table>

</form>

</td></tr></table>
</body>
</html>
====================================
dsp_SearchDisplay.cfm
====================================

<html>
<head>
      <title></title>
</head>
<body bgcolor="ffffff">
<cfif Display.Recordcount neq 0>
<cfoutput query="Display">
<font size="-1"><a href="#url#">#title#</a> -</font> <font size="-2">#description#</font>  <br>
</cfoutput>
<cfelse>
Nothing Found
<br><br>
test<br><hr>
<br>
<cfoutput>#NewText#</cfoutput>
</cfif>
</body>
</html>
==================================
act_SearchDisplay.cfm
==================================

<cfswitch expression="#SearchType#">

<cfcase value="All">
<cfset NewText = replace('#text#',' ', ',', 'all')>
<CFQUERY NAME="Display" DATASOURCE="nsnd">
SELECT      *
FROM         SearchEngine
WHERE       (title LIKE '%#Text#%') or
                                    (url LIKE '%#Text#%') or
                                    (keywords LIKE '%#Text#%') or
                                    (description LIKE '%#Text#%')
                                    
</CFQUERY>
</cfcase>

<cfcase value="Any">

</cfcase>

<cfcase value="Exact">
<CFQUERY NAME="Display" DATASOURCE="nsnd">
SELECT      *
FROM         SearchEngine
WHERE       (title LIKE '%#Text#%') or
                                    (url LIKE '%#Text#%') or
                                    (keywords LIKE '%#Text#%') or
                                    (description LIKE '%#Text#%')
                                    
</CFQUERY>

</cfcase>

<cfcase value="Normal">

</cfcase>

</cfswitch>

===================================
app_globals.cfm
===================================
<!--- define the CFAPPLICATION--->
<cfapplication name="MyApp" sessionmanagement="yes" clientmanagement="yes" setclientcookies="yes">

<!--- app_globals.cfm --->

<cfif isdefined("url.fuseaction")>
<cfset attributes.fuseaction = #url.fuseaction#>
<cfelseif isdefined("form.fuseaction")>
<cfset attributes.fuseaction = #form.fuseaction#>
<cfelseif isdefined("attributes.fuseaction")>
<cfset attributes.fuseaction = #attributes.fuseaction#>
<cfelse>
<cfset attributes.fuseaction = "Search">
</cfif>

=================================
app_locals.cfm
=================================

<cfinclude template="app_globals.cfm">
0
 
nathansCommented:
Maybe I don't understand what your asking for but you can create one youself with coldfusion?

Is you question where is a website of tutorial that will teach you HOW to create a search engine?
0
 
rkchopraAuthor Commented:
Simply, i wanna create an internal search engine for my website. I wanna know what is the best way to do so in Cold Fusion. If you can tell me any website where can i find any nice tuturial regarding search engine, it will also serve my purpose.

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
nathansCommented:
Maybe if you look at these links you can get an Idea how to create your own.


What I would do is create my own.
Table
0. ID
1. Title
2. Link
3. keywords
4. Body
5. Rating


Then I would take the Search words against 1 - 5 in that order to find matches.

What else kind of answers do you want?

Is this for  a personal site or a Bus Site.  I might be willing for a price to create one that would work for you.

Hope this helps.

0
 
rkchopraAuthor Commented:
Hi,

That is what I have done exactly 1 year ago (the structure you have suggested). Anyway, thanks for your answer and efforts.

But I faced some problems when I tried to implement advance search like what Yahoo! and other search engine provide (for example: searching like rajesh + India). Is there any possible way to do it in Cold Fusion?

The links you have sent tell how to search on the web but i am looking how to provide same kind of search options like they provide.

Regards,
Rajesh

p.s. I am doing it for a business site.
0
 
rkchopraAuthor Commented:
Pls look into the following page:
http://search.yahoo.com/search/syntax?

I want to give the visitors these kind of search options.

Rajesh
0
 
deepchandaCommented:
I would suggest using collections in this case since it allows you to search more than one keyword like if you enter "Rajesh India", the verity search engine would search for Rajesh AND India in the collection. The steps involved in setting up the collection ...
1. Register a collection name with the CF admin or using <cfcollection> tag which gets created in the default collection directory

2. Populate the collection with <cfindex ..> tag providing it the query name

3. Use <cfsearch> tag to search for the keywords entered

DC
0
 
nathansCommented:
I got you now.  I will create one just so I will know that I can do it.  So everyone who likes ColdFusion stay tuned for a way to create a Search...

without using Verity

0
 
rkchopraAuthor Commented:
Thanks everybody for your response. Deepchanda, I wanna do it without using Verity as I want more flexibility.

Thanks nathans.. I am looking for your reply as soon as possible.

0
 
nathansCommented:
Are you going to manually add to this search engine?

I am working on it...
0
 
cheekycjCommented:
Which web server are you running.

Most searches are based on some variation of Verity.

You may want to use something besides CF.

Some of the best search engines out there are:
1. The default search engine in IIS is very good.
2.  Netscape Enteprise Server comes with a search engine too and it is very customizable.

There is another one out there that is really good.  I think it is made by Alta Vista.

CJ
0
 
nathansCommented:
This is going to take awhile do you think your company would Hire me?
0
 
nathansCommented:
One other question:  Are the Url's going to only live in ONE Category?  If so I would add a Col. for Category.

Please let me know.
0
 
bigbadbCommented:
This is just a simple search depending on the values you have saved in your datasource.  A true search engine would spider the page and return pages based on words.  If this is what you are looking for, which i assume you are then cf verity is the most flexible, not to mention best performance.  All nathans suggested was a simple search on a few columns.  Not the entire site.  I think verity is you best option.  THis is how i do it and it is very fast.  check out www.ohioworks.com and search for companies.  You will notice it is very fast and returns companines using wildcards and the search criteria

Hope this help
0
 
fifilipCommented:
i'm developing an online store and therefore i'm also designing a search engine.  it will be searching in the description of the product in the database.  here he goes!
EXPLANATION:
The search options can be used by putting in front of a keyword a + or - sign.
      + means that the keyword must be included: AND
      - means that the keyword may NOT be included: NOT
      nothing in front stands for a logical OR
      
This template only handles the parsing of the search string.

NOTE 1:  i also kept the boolean value with each keyword.  this however seems to be redundant, since after parsing:
a 'and keyword' always starts with a "+"
a 'not keyword' always starts with a "-"
a 'or keyword' is that which doesn't fit in the above

NOTE 2: i didn't (yet) implemented the WHERE part of the sql statement, since the combination of AND and OR doesn't always seem to make sense.  can anyone clarify (probably this is something for the sql section)?
you should get something like this:
select * from item where name like '%word[1]%' and not name not like 'word[2]'        (does it seems logical to anyone to add here an OR statement? -- maybe this is a question for the sql section)

NOTE 3: searching for a string: eg +tjechov +"the bear"
still thinking about it ... (was getting late yesterday :) )
perhaps:
FIRST locate a begin and end apostrophe and all between is one word[i]
analogy:      
*use mid() for searching
*remember beginpos of first apostrophe
*remember endpos of 2nd apostrophe
*extracted=mid(string,beginpos[i],eindpos[i]-beginpos[i])(see cfdoc for usage of mid)
THEN: remove extracted from string with removechars() (cfdocs !)
continue with the above, looking for '+' '-' ' '

HTML form --> Form.what --> test2.cfm

<!--- DECLARE OR INITIALIZE --->
<cfset j=0><!--- set wordcount=0; no words yet found, ofcourse! --->

<cfset word=arraynew(1)><!--- define array for keywords --->
<cfset startpos=arraynew(1)><!--- define array for beginposition of keywords --->
<cfset bool=arraynew(1)><!--- define array for which boolean to use per keyword --->

<cfset Form.what=" " & trim(Form.what)><!--- Bug fix: trim string and add one leading space for detecting possible first OR string --->
<!--- END OF DECLARATION --->

<!--- BEGIN PARSING THE STRING --->
<cfoutput>Totale lengte=#len(Form.what)#<br><br></cfoutput>

<cfloop index=x from=1 to='#len(Form.what)#'>

      <cfset t=mid(Form.what,x,1)>
      
      <cfoutput><b>#x# #t#</b></cfoutput>
      
      <cfswitch expression='#t#'>
            
            <cfcase value="+">
                  <!--- increment the wordcount 'j' --->
                  <!--- remember start pos of word 'j' and its boolean value, ie. AND --->
                                    
                        <cfscript>
                        j=j+1;
                        startpos[j]=x;
                        bool[j]="and";
                        </cfscript>
                        <cfoutput><i>#bool[j]#</i> gevonden; woord begint op positie #startpos[j]#. </cfoutput>
            </cfcase>      
            
            <cfcase value="-">
                  <!--- increment the wordcount 'j' --->
                  <!--- remember start pos of word 'j' and its boolean value, ie. OR --->
                  
                        <cfscript>
                        j=j+1;
                        startpos[j]=x;
                        bool[j]="not";
                        </cfscript>
                        <cfoutput><i>#bool[j]#</i> gevonden; woord begint op positie #startpos[j]#. </cfoutput>
            </cfcase>
                              
            <cfcase value=" ">
                  <!--- first, check if next char is NOT + NOR - NOR space. a new word only starts after a + or -; blanks are ignored  --->
                  
                  <cfset next=mid(Form.what,x+1,1)>
                  <cfif NOT((next eq "+") OR (next eq "-") OR (next eq " "))>
                        
                        <!--- increment also the wordcount 'j' --->
                        <!--- remember start pos of word 'j' and its boolean value, ie. AND --->
                        
                        <cfscript>
                        j=j+1;
                        startpos[j]=x;
                        bool[j]="or";
                        </cfscript>
                        <cfoutput><i>#bool[j]#</i> gevonden; woord begint op positie #startpos[j]#. </cfoutput>
                  <cfelse>
                        <cfoutput>  ignore blanks</cfoutput>
                  </cfif>
            </cfcase>
            
            <cfdefaultcase>
                  <cfoutput>no special character found</cfoutput>
            </cfdefaultcase>
            
      </cfswitch>
      
      <!--- set virtual next wordposition to calculate last endwordposition --->
      
      <cfset startpos[j+1]=len(Form.what)+1>
      
      <br>
      
</cfloop>

<cfoutput><br>I've found the following #j# words in <b><i>#Form.what#</b></i>:<br><br></cfoutput>
      

<cfloop index=y from=1 to=#j#>
      <cfset word[y]="#mid(Form.what,startpos[y],startpos[y+1]-startpos[y])#">
      <cfoutput>
      Woord[#y#]: <i>#word[y]#</i>   Boolean: <i>#bool[y]#</i><br>
      </cfoutput>
</cfloop>

<!--- END PARSING THE STRING --->

<!--- BEGIN COMPOSING THE 'WHERE' PART OF QUERY --->

<cfoutput><a href="options.html">Terug zoeken</a></cfoutput>

HOPE THIS helps...
0
All Courses

From novice to tech pro — start learning today.