Searching Engine

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
artfhc
Forum Newbie
Posts: 23
Joined: Sun May 23, 2004 11:38 pm
Contact:

Searching Engine

Post by artfhc »

I am wondering if someone can explain to me how searching engine works in php. DO I have to put every single information into my database, since I used mysql, so it would be easier for me to make one? I am sure that there should be some smarter and more advance way to do so. Thankyou!!! :idea:
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Well, it really depends on what you're searching for exactly and what you're searching on.
The 2 common types of search are:
1) SELECT * FROM foo WHERE something LIKE '%somesearchterm%';
2) Use MySQL's FULLTEXT search
artfhc
Forum Newbie
Posts: 23
Joined: Sun May 23, 2004 11:38 pm
Contact:

Post by artfhc »

so the only way to search things is to save every imformation in the database, then use the utility of mysql or other database language to search it, right? I am actually hoping if there are some other way whether than using all database. I don't understand the fact that yahoo and google can search things freely without saving everything in database. I want to know how they work.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Dynamic pages will (usually) have content stored in a db for which you obviously have to do a db search.

If you also have a lot of static pages, you can use php file fns & regex to look for search terms in the html files.
Yonderknight
Forum Commoner
Posts: 31
Joined: Sun Jun 13, 2004 6:51 pm

Post by Yonderknight »

Can't you use a database to store the names of all your files, then use PHP to open the files and look using a string search?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I don't think there's a need to store filenames in the db: the filesystem IS the db.

Some kind of recursive tree iterator might be used to hunt through folders & sub-folders, starting at the web root. You may want to exclude some folders from the search.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

artfhc wrote:so the only way to search things is to save every imformation in the database, then use the utility of mysql or other database language to search it, right? I am actually hoping if there are some other way whether than using all database. I don't understand the fact that yahoo and google can search things freely without saving everything in database. I want to know how they work.
Last time I checked, Google stored everything in a database.
Yes, EVERYTHING. (besides images of course).

Imagine having that kind of space in your PC. :P
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

artfhc wrote:so the only way to search things is to save every imformation in the database, then use the utility of mysql or other database language to search it, right? I am actually hoping if there are some other way whether than using all database. I don't understand the fact that yahoo and google can search things freely without saving everything in database. I want to know how they work.
There are algorithms for searching. I don't know them tho.
Using db's 'like' command is the slow way. You can use that for a small search space, but need much better stuff for bigger search. Like if google used that, there is no way they could search 5 billion texts in under 0.1 seconds.
artfhc
Forum Newbie
Posts: 23
Joined: Sun May 23, 2004 11:38 pm
Contact:

Post by artfhc »

This is kind of frustrating though, about the way to store everg single thing in database. So that means that google can only search things that are stored in their database? This is so unbelievable...but oh well.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

google's database is stored almost entirely in RAM at all times. Their bot is continually crawling their systems to update their cache, as well as spidering the links on the pages. We may see some of how Google works internally, soon.. :)
Post Reply