+1 to zend_search_lucene over rolling your own global search (unless
you have a small number of db tables). There is a tutorial on the
Bakery (http://bakery.cakephp.org/articles/view/integrating-zend-
framework-lucene-with-your-cake-application) that helps getting it
into the system. As an anecdotal benchmark, I built a system for a
client that now has over 3000 customer records in the DB, the client
reckons that the Zend search is faster than doing a findAll type
search.

A couple of gotchas with zend_search_lucene: (i) it is PHP5 only; (ii)
it can take some fiddling to install; (iii) it cannot yet do "fuzzy"
searches, i.e. the equivalent of LIKE statements.

Cheers, Ianh

On Aug 12, 8:54 am, kabturek <[EMAIL PROTECTED]> wrote:
> That will be a lot of findAlls... and LIKE is a db killer;) Also you
> would like to set recursive to -1 when searching.
> This is a little out of scope but some index optimization is a must in
> your solutionhttp://www.databasejournal.com/features/mysql/article.php/1382791
>
> I've did simple searches this way 
> :http://wiki.kabturek.info/paginating_search_results
>
> Did you look at the more advanced solutions like Zend_Seach_Lucene ?
> The only downside is that it can't limit the number of results
> returned and can't paginate thru the results...
>
> I hope i don't get killes by publishing this link 
> ;)http://www.symfony-project.com/askeet/en/21
> It's a nice tutorial on building a search engine.
> Also there was a nice article in PHP Slutions about building a bitset
> search engine .
>
> If you're using PostgreSQL take a look at 
> tsearchhttp://www.pgcon.org/2007/schedule/events/13.en.html
>
> I haven't looked at Xapian myself so aonly a link:http://www.xapian.org/
>
> greets,
> Marcin Domanski aka kabturek
>
> On Aug 11, 8:31 pm, savagekabbage <[EMAIL PROTECTED]> wrote:
>
> > I wanted to incorporate a simple Global Record Search into my cart
> > (Selling Made Simple), and this is how I did it if anyone's wondering.
> > This example will basically allow you to search any model by any any
> > field depending on what you put in the database.
>
> > This code is from Selling Made Simple and is released under the GPL.
> > If you see something that could be better about this code, please let
> > me know!
>
> > 1 - Create a new model and database table, something like this is what
> > I used:
>
> > CREATE TABLE `search_tables` (
> >   `id` int(10) NOT NULL auto_increment,
> >   `model` varchar(50) NOT NULL,
> >   `field` varchar(50) NOT NULL,
> >   `url` varchar(50) NOT NULL,
> >   `edit_field` varchar(50) NOT NULL,
> >   `alternate_anchor` varchar(50) NOT NULL,
> >   PRIMARY KEY  (`id`)
> > )
>
> > 2 - Create a basic form that will post to your controller.  Mine looks
> > something like this:
>
> > echo $form->create('Search', array('action' => '/search/
> > admin_global_search/', 'url' => '/search/admin_global_search/'));
> > echo $form->input('Search/term');
> > echo $form->submit();
> > echo $form->end();
>
> > 3 - My controller looks something like this:
>
> > function admin_global_search ()
> > {
> >         $search_tables = $this->Search->findAll();
> >         $search_results = array();
>
> >         foreach($search_tables AS $key => $table)
> >         {
> >                 $search_results[$key] = array();
> >                 loadModel($table['Search']['model']);
> >                 $this->SearchModel =& new $table['Search']['model']();
>
> >                 $search_conditions = $table['Search']['model'] . '.' .
> > $table['Search']['field'] . ' LIKE \'%' . $this->data['Search']
> > ['term'] . '%\'';
>
> >                 $search_results[$key] = 
> > $this->SearchModel->findAll($search_conditions,null,null,20);
>
> >         }
>
> >         $this->set('tables',$search_tables);
> >         $this->set('results',$search_results);
>
> >         $this->render('','admin');
>
> > }
>
> > 4 - The view would of course just loop through the records and display
> > the data.  I won't bother posting that here, since that's probably
> > dependent on your application and need.
>
> > 5- Add models to search to your database.  For example Selling Made
> > Simple has something like this:
>
> > INSERT INTO `search_tables` (`id`, `model`, `field`, `url`,
> > `edit_field`, `alternate_anchor`) VALUES
> > (1, 'Content', 'alias', '/contents/admin_edit/', 'id', ''),
> > (2, 'Content', 'head_data', '/contents/admin_edit/', 'content_id',
> > ''),
> > (3, 'ContentDescription', 'name', '/contents/admin_edit/',
> > 'content_id', ''),
> > (4, 'ContentDescription', 'description', '/contents/admin_edit/',
> > 'content_id', 'name'),
> > (5, 'ContentLink', 'url', '/contents/admin_edit/', 'content_id', ''),
> > (6, 'Language', 'name', '/languages/admin_edit/', 'id', '');
>
> > -----------------------------
> > Kevin Grandon
> > sellingmadesimple.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to