Re: search results return by relevancy

From: Date: Thu, 19 Apr 2001 15:13:29 +0000
Subject: Re: search results return by relevancy
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49378@lists.php.net to get a copy of this message
Note that a LIKE query like that is going to be very slow. You are better off defining those fields as fulltext fields and using MySQL's built-in fulltext search capability which will automatically return a relevance value for each hit. See http://www.mysql.com/doc/F/u/Fulltext_Search.html -Rasmus On Thu, 19 Apr 2001, Jen Hall wrote: > Hi there > I have some scripts that do a search in a MySQL database > table. > I want to be able to return rows that match a query, in > order of relevancy. > For example, say I have a table that has the following data > > |row_id| data > |------|------------------------------------- > | 1 | cat > | 2 | cat cat > | 3 | cat cat cat > | 4 | cat cat > | 5 | cat cat cat cat cat cat cat > | 6 | cat > | 7 | cat cat cat cat > | 8 | cat cat cat cat cat > > I want to do a search that would return row_id 5 first, then > > row_id 8, then row_id 7, then 3, etc. > So I want to order the return by relevancy. > What should the sql query look like? > select * from table where data like '%cat%' order by ????? > > thanks > -jen >

« previous php.general (#49378) next »