Jump to content

MySQL Weighted Search


YorkshireSteve

Recommended Posts

Hi All,

 

I'm creating a basic search on a website and want to sort results by relevance. I'm using InnoDB tables so can't use Full-Text searches, but want to order results be relevance.

 

I am searching in title (varchar) and description (longtext), and want items to be sorted based on the number of times a term appears, and where. For example, for every time 'bath' appears in the `title` column, it scores 3 points, whereas for every instance in the `description` column it scores one point. I know there are plenty of ways I can do this with my PHP front-end, but I'm wanting to try this in MySQL (after all, this is part of the data-retrieval process).

 

Any comments are much appreciated!

 

Thanks,

 

Steve

Link to comment
https://forums.phpfreaks.com/topic/105744-mysql-weighted-search/
Share on other sites

Without fulltext you'll have to build your own indexing tables.

 

One table for keywords and the other for linking those keywords to whatever other data you're indexing along with the keyword weight.

 

I suggest you use the porter stemming method for extracting keywords.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.