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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a search engine for a website 1

Status
Not open for further replies.

thanh1800

Technical User
Aug 2, 2006
43
0
0
AU
I have a website and I want people to be able to search this site.

Can anyone tell me how I might be able to get this done please?
 
The link that you show provides the source code that you need, along with clear and simple instructions. What else do you need, or what difficulty are you having with those instructions?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
thanh1800, are you saying you like what google site search does, but want to custom develop one (as in not use the google service)?

If so, you'd need to:
1. Find out what server-side script your site uses
2. What dB (this doesn't matter much but helps in giving advise)

If you want to use the google service instead, can you explain what it is you need?

____________________________________
Just Imagine.
 
Yes I would like to custom develope one.

Well after some research i have decided to create my own search site using java script

It not great but it will have to do.

It will involve me index(ing) the website then using string functions (apend,replace,split,search) to process the search and result page.

I'll post the script when I am done.

But feel free to show me any other method

ps I dont know how to get the server info you requested (server-side script)

@johnwm
source code? can you copy and paste them into this thread please because I didnt see any.

ps source code to me is not just the interface.
 
Wow thanks GUJUm0deL

I will use this for now with your authorship on.

but I am still going to make my own.

javascript is easy for me and if I could I would do everything in javascript, but there are other technologies out there that I want to try out.
 
As you're posting in the web designers forum, rather than the javascript forum I assumed you wanted some code to put on your page to do the google search. If you are looking for a JS hand written solution, then use GUJUm0deL's FAQ, or ask further in forum216

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
@Johnwm
oh nah I wasn't after javascript codes

I have a website that needs 'a' search engine

one solution was javascript...
that I can do but i was wondering if there were another way to solove this problem.

------------code-----------------
well here it is, its not perfect or CLEAN but it works (to an extent)

just copy it into a file ending with .htm

<html>
<title></title>
<head>

<script>

var Indexed_Webpage = new Array();
Index=0; Indexed_Webpage[Index]=new Array(0, "Cat_Webpage", "all about cats", " There are dozens of breeds of cat, some hairless or tailless as a result of mutations, and they exist in a variety of different colors. They are skilled predators and have been known to hunt over one thousand different species for food. They are also intelligent animals, and some can be trained or learn by themselves to manipulate simple mechanisms such as lever-handled doors and flush toilets ");
Index++; Indexed_Webpage[Index]=new Array(0, "Cat2", "Cat relation", " Much like some other domesticated animals (such as the horse), cats may also still live effectively in the wild as a feral cat. Contrary to the popular conception of the cat as a solitary animal, cats often form small colonies in the wild. ");
</script>

<script>
function Set_Document_innerHTML(ID_Name, innerHTML){
document.getElementById(ID_Name).innerHTML = unescape(innerHTML);
};
</script>
<base target="Main">
</head>

<body>

<table dir="ltr" cellSpacing="0" cellPadding="0" width="100%" border="0" id="table1">
<tr>
<td vAlign="top" align="center"><p>You may search our
web site for all
documents containing matching words or patterns.</p>
<p>try cat<br>
then skilled<br>
than cat skilled<br>
then c<br>
then apple</p>
<form id="Search_Form" name="Search_Form" method=get action="javascript:void(0)" onsubmit="Run_Search(document.Search_Form.Search_Form_Text.value)">
<p>
<input id="Search_Form_Text" name="Search_Form_Text" type="text" size="20">
<input type="submit" value="Submit" name="B4">
<input type="reset" value="Reset" name="B2"></p>
</form>

<div id="Search_Display">
</div>


</td>
</tr>
</table>

</body>

</html>


<script>
var Show_Size = 150;
var Page_ID = 0;
var Found_Color = "#0000FF"
var Found = "";
var Display = "";
var Content = "";
var Temp_Content = "";
var Heading_Frag = "";
var Content_Frag = "";
var Global_Temp;
var zxc = "";

function Run_Search(Var1)
{
Heading_Frag = "";
Content_Frag = "";
Found = "";
for(For_Index = 0; For_Index < Indexed_Webpage.length ; For_Index++){
Indexed_Webpage[For_Index][0] = 0;
}

Temp2 = Var1;
Global_Temp = Temp2.toLowerCase().split(" ");
For_Index = 0;
For_Index1 = 0;

Display = "<table border=\"0\" width=\"90%\"><tr><td>";

for(For_Index1 = 0; For_Index1 < Global_Temp.length ; For_Index1++){
for(For_Index = 0; For_Index < Indexed_Webpage.length ; For_Index++){
if(Indexed_Webpage[For_Index][0] < 1){
if(Search(For_Index, Global_Temp[For_Index1], 3)!= "Not Found"){
Indexed_Webpage[For_Index][0] = 1;
Content_Frag += Search(For_Index, Global_Temp[For_Index1], 3) + " ~qwert~ ";
Heading_Frag += "<p><a href=\"" + Indexed_Webpage[For_Index][1] + "\">" + Indexed_Webpage[For_Index][2] + "</a></p><p> ~qwert~ ";
//Found += "<p><a href=\"" + Indexed_Webpage[For_Index][1] + "\">" + Indexed_Webpage[For_Index][2] + "</a></p><p>" + Search(For_Index, Temp[For_Index1], 3) + "<br><hr></p>";
}
}
}
}
if(Heading_Frag != ""){
Color_Search();


Format_Length = 30;
for(For_Index9 = 0; For_Index9 < Global_Temp.length ; For_Index9++){
For_Index1=0;
while(For_Index1 < Content_Frag.length){
Found_Index = Content_Frag.toLowerCase().indexOf(" "+Global_Temp[For_Index9], For_Index1);
if(Found_Index > -1){
Found_Index_End = Content_Frag.indexOf(" ",Found_Index+1)
Content_Frag = Content_Frag.substring(0, Found_Index) + "<font color=\"" + Found_Color + "\">"
+ Content_Frag.substring(Found_Index, Found_Index_End) + "</font>"
+ Content_Frag.substring(Found_Index_End, Content_Frag.length);
For_Index1 = Found_Index_End+Format_Length;
} else{
For_Index1 = Content_Frag.length+1;
}
}
}


Head = Heading_Frag.split(" ~qwert~ ");
Body = Content_Frag.split(" ~qwert~ ");
for(For_Index = 0; For_Index < Head.length-1 ; For_Index++){
Display += Head[For_Index] + Body[For_Index] + "<br><hr></p>";
}
}

Display += "</td></tr></table>";



//zxc += Global_Temp[For_Index1];
Set_Document_innerHTML("Search_Display", Display);

//document.write(Display);
//document.write(zxc);
}


function Search(Var1, Var2, Var3)
{
Temp_Content = "Not Found";
Content = Indexed_Webpage[Var1][Var3].toString();
Reg_Exp = new RegExp(" "+Var2, "gi");
Index_Word = Content.search(Reg_Exp);
Index = Index_Word;
if(Index > -1){
if(Index-40 < 0){
Index = 0;
if(Index+Show_Size > Content.length){
Index_Last = Content.length;
} else{
Index_Last = Index+Show_Size
Index_Last = Content.indexOf(" ",Index_Last)
}
} else{
Index = Index-40
Index = Content.indexOf(" ",Index)
if(Index+Show_Size > Content.length){
Index_Last = Content.length;
} else{
Index_Last = Index+Show_Size
Index_Last = Content.indexOf(" ",Index_Last)
}
}
Index_Word_End = Content.indexOf(" ", Index_Word+1)
Temp_Content = Content.substring(Index, Index_Last)
}
return Temp_Content;
}

function Color_Search(){
}
</script>

------- end code --------

sorry about the mess everyone
and dont worry about the mess I know how to fix it up and I will do it later
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top