user188962
user188962

Reputation:

What should I do, create a search engine myself or use another one?

I have this classifieds website and I have now been searching for ways to implement a search function of the classifieds.

I wonder, is there any tutorial for creating a pretty powerful search engine in PHP that you know of?

I have looked into third party search engines, and it feels they are too much...

PS: No full-text support on my server.

Thanks

Upvotes: 2

Views: 403

Answers (6)

BalusC
BalusC

Reputation: 1109262

If performance matters more than memory/storage, then I would recommend Xapian. Its performance is impressive in case of gigantic large databases (in terms of GB's). Under each the social bookmarking site delicious.com and the Dutch biggest PC-related forum Gathering of Tweakers uses it and I was been close to the choice, development and integration of the search engine. It heavily outperformed other search engines.

Upvotes: 0

Square Rig Master
Square Rig Master

Reputation: 644

Camran

I use a very powerful third party search engine. It is a little pricy but very powerful.

have a look here:

dtSearch

Upvotes: 0

Yacoby
Yacoby

Reputation: 55465

To be honest, I would recommend using Zend_Lucene, as although it looks confusing at first, it is very simple to use once you get to grips with it. Although indexing is slow, searching is very fast.

If you want to write a fast and powerful search engine, you are not going to find an implementation in a tutorial, you would be best of doing some research and reading so papers on the subject. In other words, you are not going to be able to write anything in PHP to rival Zend Lucene without a lot of research and hard work.

The documents are very very good, and I have managed to implement Zend Lucene in a none zend framework based project. It just requires half an hour spent reading and digesting the documents and another half hour writing a quick set of tests to check your assumptions are correct.

To create a document with a car id and make:

//if it hasn't been created, you need to use ::create rather than ::open
$index = Zend_Search_Lucene::open('/data/my-index');

$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('Car', 'MyCar'));
$doc->addField(Zend_Search_Lucene_Field::Text('Make', 'BMW'));

$index->addDocument($doc);

The to find the cars:

$index = Zend_Search_Lucene::open('/data/my-index');
$result = $index->find('Car:MyCar');

foreach ( $result as $hit ){
    echo $hit->Make;
}

The downside is that Zend_Lucene isn't a storage engine, it doesn't make any guarantees about the storage, so although you can use it to store records, using a proper database would be a better option. This is one of the issues that I encountered, you just have to keep both the search index and the database synchronized. The best way I found was just to create a wrapper class that called add/remove on both the database and the index.

Upvotes: 6

Gordon
Gordon

Reputation: 317129

Given that you have already looked into Sphinx and Lucene and feel they are too complicated/big to implement, why not interface with one of the existing Search Engines. You might also be interested in this article explaining why writing a search engine is hard

Upvotes: 2

miku
miku

Reputation: 188124

A typical open-source mindset is to reuse anything out there.

  • it saves time
  • you probably learn about new technology somebody else might know more about
  • give back by own contributions, bug-fixes, enhancements

Of course this applies only for a project, which meet your needs. If you think, the available stuff is too much for your site, go write your own, you'll learn something new, too ...

Upvotes: 2

Kemo
Kemo

Reputation: 7042

You should look at Lucene, Zend has made quite a good library;

Zend_Search_Lucene

Upvotes: 1

Related Questions