English 中文(简体)
FULL TEXT SEARCH in cakephp ? any example
原标题:

I am using ordinary search functionality in my business controller . but now need to implement FULL TEXT SEARCH with paginate can any one give idea or sample ? I am using MySQL with MyISAM tabes

and this my table structure, fields marked bold are need to use in search

CREATE TABLE IF NOT EXISTS businesses ( 
  id bigint(20) unsigned NOT NULL AUTO_INCREMENT, 
  created date NOT NULL, 
  modified datetime NOT NULL, 
  user_id bigint(20) NOT NULL, 
  slug varchar(255) NOT NULL, 
  **`name` varchar(255) NOT NULL,** 
  **street_name varchar(255) DEFAULT NULL,** 
  **shopping_center varchar(255) DEFAULT NULL,** 
  state_id int(10) NOT NULL, 
  suburb_id int(10) NOT NULL, 
  zip_code varchar(12) DEFAULT NULL, 
  website varchar(250) DEFAULT NULL, 
  email varchar(255) DEFAULT NULL, 
  phone_no varchar(255) NOT NULL, 
  mobile_no varchar(255) DEFAULT NULL, 
  fax varchar(255) DEFAULT NULL, 
  is_active tinyint(1) NOT NULL DEFAULT  1 , 
  PRIMARY KEY (id) 
) ENGINE=MyISAM  DEFAULT CHARSET=latin1; 
最佳回答

After you have created your FULLTEXT indices it s not different at all from normal paginate conditions, you just need to construct your SQL a little more manually and most importantly escape the user input manually.

$query =  foobar ; // the user input to search for
$escapedQuery = $this->Business->getDataSource()->value($query);

$this->paginate[ conditions ] = array("MATCH (Business.name) AGAINST ($escapedQuery)");
$businesses = $this->paginate();
问题回答

暂无回答




相关问题
Acronyms with Sphinx search engine

how can i index acronyms like m.i.a. ? when i search for mia , i get results for mia and not m.i.a. . when i search for m.i.a. , i get nothing at all. edit: solution looks roughly like: ...

Querying multiple index in django-sphinx

The django-sphinx documentation shows that django-sphinx layer also supports some basic querying over multiple indexes. http://github.com/dcramer/django-sphinx/blob/master/README.rst from ...

Adding Search to Ruby on Rails - Easy Question

I am trying to figure out how to add search to my rails application. I am brand new so go slow. I have created a blog and done quite a bit of customizing including adding some AJAX, pretty proud of ...

Searching and ranking short phrases (e.g. movie titles)

I m trying to improve our search capabilities for short phrases (in our case movie titles) and am currently looking at SQL Server 2008 Full Text Search, which provides some of the functionality we ...

Will Full text search consider indexes?

Ok I have a full text search index created on my JobsToDo table, but what I m concerned about is if this is rendering my other indexes on the table useless. I have a normal nonclustered index on the ...

Lucene.NET on shared hosting

I m trying to get Lucene.NET to work on a shared hosting environment. Mascix over on codeproject outlines here how he got this to work on godaddy. I m attempting this on isqsolutions. Both ...

Hibernate Search or Compass

I can t seem to find any recent talk on the choice. Back in 06 there was criticism on Hibernate Search as being incomplete and not being ready to compete with Compass, is it now? Has anyone used both ...

热门标签