Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Recommendations for site search



4:35 pm on Dec 23, 2011 (gmt 0)

Forgive me if this is the wrong area to ask.
I'm looking for a PHP site search script that will search in one directory for xls, pdf, and metatags for pages corresponding to what the visitor is looking for. No need for database or flat files.

After much searching, I'm coming up empty. Any have some recommendations? Or any thoughts about building it myself?
Thanks Guys!


5:00 pm on Dec 23, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Have you considered just integrating Google's site search (or one of the other S.E.'s free search tools?)


3:09 pm on Dec 27, 2011 (gmt 0)

Would prefer to have the control a script offers, but thanks for the suggestion.


10:40 pm on Dec 27, 2011 (gmt 0)

10+ Year Member

I've been using Sphinx search for quite some time. It's exceptionally fast and fairly easy to setup and configure. They've just released a new stable version with additional features.


11:05 pm on Dec 27, 2011 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

>>No need for database or flat files.

how is it going to work then? is the php script going to open every file to read the meta tags, read every pdf and excel document each time the search is initiated?


3:08 pm on Dec 28, 2011 (gmt 0)

Okay, just my lack of experience talking. I had seen a couple that didn't use either flat or db.

Hazmat- I'll check it out. Thanks!


5:15 pm on Dec 28, 2011 (gmt 0)

The server is not my own, and I do not have shell access. So Sphinx isn't going to work. Too bad, it looked like a good one. Any other thoughts?


7:41 pm on Dec 28, 2011 (gmt 0)

10+ Year Member

How many files are we talking about on the server that will be indexed?

There are a couple of different options i can think of off the top of my head that will work pretty well.
I'm assuming this site isn't getting a lot of traffic and high performance isn't essential.

If it were just a small selection of xls and pdfs *filenames*, I'd probably just say to search on the fly. You could just readdir, then pattern match the filenames. I guess you could do the same with the html files, but as topr8 implied, reading that's going to be really slow for a moderate amount of results and not a good long term solution.

Best solution, because your search is so specific, it would be quite easy to create a database table, setup a script to load all of your files into the table, then use that on your search script.

Just create a table something like this:

id | search_term | uri

Setp a php script to index the files, and load it into your database, and maybe setup a cron to do this automatically.

Then perform your search on the database when your user searches, with a simple query such as:
$query = "SELECT uri FROM simple_site_search WHERE keyword LIKE '" . mysql_real_escape_string($keyword) . "'";
Or something like that, you probably get the idea.

HTH, let us know if you need more advice.


3:33 pm on Dec 29, 2011 (gmt 0)



5:03 am on Jan 3, 2012 (gmt 0)

5+ Year Member

Something I just ran across was glob [php.net...]


4:18 pm on Jan 3, 2012 (gmt 0)

hmmm. Interesting.

Featured Threads

Hot Threads This Week

Hot Threads This Month