Jump to content

multiple keyword search order


poelinca

Recommended Posts

create table keyword_relevance

( id tinyint not null primary key auto_increment

, Description longtext

);

insert into keyword_relevance (Description) values

('Hello world')

,('hello friends from around the world')

,('friends from around the world')

,('hello my friends')

,('the keyword is not present');

 

 

Oki so up until now i was retreving my search results by "SELECT description FROM keyword_relevance WHERE description REGEXP '(hello|world)';"

 

Now i need to order this result based on the occurence of the search keywords , the more different keywords found in one row the higher will "rank" in the search result query . Question is , can it be done from the sql query ? or do i need to work the php bit to search for each keyword in a different query then test they'r id's and ...

Link to comment
Share on other sites

  • 4 weeks later...

CREATE TABLE `ci_articles` (

  `id` int(11) NOT NULL auto_increment,

  `title` varchar(255) default NULL,

  `content` longtext,

  `date` int(11) default NULL,

  `author` varchar(255) default NULL,

  `cat` int(11) default NULL,

  `is_page` tinyint(4) default NULL,

  `permalink` varchar(255) default NULL,

  `page_desc` varchar(255) default NULL,

  `page_key` varchar(255) default NULL,

  PRIMARY KEY  (`id`),

  FULLTEXT KEY `title` (`title`,`page_key`,`page_desc`,`permalink`)

) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8

 

 

running the query

SELECT * FROM ci_articles WHERE MATCH(title, page_key) AGAINST('sasa')

 

produces

Error Number: 1191

 

Can't find FULLTEXT index matching the column list

 

Link to comment
Share on other sites

CREATE TABLE `ci_articles` (

  `id` int(11) NOT NULL auto_increment,

  `title` varchar(255) default NULL,

  `content` longtext,

  `date` int(11) default NULL,

  `author` varchar(255) default NULL,

  `cat` int(11) default NULL,

  `is_page` tinyint(4) default NULL,

  `permalink` varchar(255) default NULL,

  `page_desc` varchar(255) default NULL,

  `page_key` varchar(255) default NULL,

  `search_content` longtext NOT NULL,

  PRIMARY KEY  (`id`),

  FULLTEXT KEY `title` (`title`,`page_key`)

) ENGINE=MyISAM AUTO_INCREMENT=31 DEFAULT CHARSET=utf8

 

 

running the query

SELECT * FROM ci_articles WHERE MATCH(title, page_key) AGAINST('sasa')

 

produces

Error Number: 1096

 

No tables used

 

SELECT *

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.