1

I want to build a in-site search engine with php. Users must login to see the information. So I can't use the google or yahoo search engine code.

I want to make the engine searching for the text and pages, and not the tables in mysql database right now.

Has anyone ever done this? Could you give me some pointers to help me get started?

2
  • 1
    I have written a search engine before. If you want any kind of half-way decent performance, it takes a lot of code. I would recommend finding a plugin of some type.
    – twolfe18
    Nov 10, 2009 at 15:39
  • @twolfe18 Thanks for your advice, while i'm searching for some tools such as sphider1.3.4, but it doesn't work this version. Do you know some other tools or plugins?? Thanks. Nov 10, 2009 at 15:41

6 Answers 6

3

you'll need a spider that harvests pages from your site (in a cron job, for example), strips html and saves them in a database

2
  • @Frankie, what do you recommend? Feb 25, 2010 at 16:37
  • @garcon1986 a search engine will have to use databases of some sort to have any kind of speed. There are several that will do just fine, google Sphinx or Lucene like Arnaude suggested . Doing it on files just wont do the trick.
    – Frankie
    Feb 26, 2010 at 18:34
3

You might want to have a look at Sphinx http://sphinxsearch.com/ it is a search engine that can easily be access from php scripts.

1

I have used sphider finally which is a free tool, and it works well with php.

Thanks all.

0

You can cheat a little bit the way the much-hated Experts-Exchange web site does. They are for-profit programmer's Q&A site much like StackOverflow. In order to see answers you have to pay, but sometimes the answers come up in Google search results. It is rather clear that E-E present different page for web crawlers and different for humans. You could use the same trick, then add Google Custom Search to your site. Users who are logged in would then see the results, otherwise they'd be bounced to login screen.

4
  • To be clear, EE presents a different page to crawlers and to visitors from google. Nov 10, 2009 at 10:48
  • that is called cloaking and I wouldn't recommend it. (even if EE does it, they have some special agreements with google about it)
    – dusoft
    Nov 10, 2009 at 10:50
  • If that requires some special agreement - it's probably a no go then. Nov 10, 2009 at 11:08
  • When the solution appears on Google you can scroll down the page - to the very bottom of all that crap - and the solution will be visible to the user. That goes along with Google's guidelines - no need for special agreements.
    – Frankie
    Feb 26, 2010 at 18:33
0

Do you have control over your server? Then i would recommend that you install Solr/Lucene for index and SolPHP for interacting with PHP. That way you can have facets and other nice full text search features.

I would not spider the actual pages, instead i would spider pages without navigation and other things that is not content related.

SOLR requiers Java on the server.

3
  • Thanks, but i think it's more complex for me to use java. Do you have other recommendations? Nov 10, 2009 at 15:45
  • It's not that diffircult and you will have a very powerful search engine. There is absolutely no java programming involved. The simpler aproach is the mysql way. Put upp views that you query.
    – Fontanka16
    Nov 10, 2009 at 16:44
  • Thank you Fontanka, i will try to use SolPHP. Nov 10, 2009 at 22:27
0

If the content and the titles of your pages are already managed by a database, you will just need to write your search engine in php. There are plenty of solutions to query your database, for example:

http://www.webreference.com/programming/php/search/

If the content is just contained in html files and not in the db, you might want to write a spider.

You may be interested in caching the results to improve the performances, too.

I would say that everything depends on the size and the complexity of your website/web application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.