Re: Homebrew fulltext search function (help)
| From: | Richard Lynch | Date: | Tue, 01 Feb 2005 18:05:19 +0000 |
| Subject: | Re: Homebrew fulltext search function (help) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207844@lists.php.net to get a copy of this message | ||
Jason Morehouse wrote:
> within a sqlite call. This pases matched content to a function, where
> the function needs to pass back a score:
>
> sqlite_create_function($sDB, 'fulltext', 'fulltext_step',2);
>
> function fulltext_step($title, $content) {
> $words = explode(' ', strtolower('php books'));
$words = explode(' ' , strtolower($title));
> $content = explode(' ',strtolower($content));
> $content = array_intersect($content,$words);
> foreach($content as $wordpos => $word) {
> print "$wordpos - $word<br>";
> }
return count($content);
> }
That's a crude first take.
You could also add mega-points for, say, stristr($title, $content) for an
exact match, or more points for proximity of $word within $content (which
you'd need to do a different algorithm than above) or...
--
Like Music?
http://l-i-e.com/artists.htm