在介绍个这两天折腾的东西phpsou 开源的搜索
结果都是淘宝客 [*]CREATE TABLE IF NOT EXISTS `ve123_links` ([*]`link_id` mediumint(9) NOT NULL auto_increment,
[*]`title` varchar(225) NOT NULL,
[*]`tuiguang` int(11) NOT NULL,
[*]`site_id` mediumint(9) NOT NULL,
[*]`url` varchar(325) NOT NULL,
[*]`keywords` mediumtext NOT NULL,
[*]`description` mediumtext NOT NULL,
[*]`fulltxt` mediumtext NOT NULL,
[*]`pagesize` float NOT NULL,
[*]`level` int(11) NOT NULL,
[*]`addtime` int(11) NOT NULL,
[*]`updatetime` int(11) NOT NULL,
[*]`lrymd5` varchar(32) NOT NULL,
[*]PRIMARY KEY(`link_id`)
[*]) ENGINE=MyISAM DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;复制代码[*] function q($wd,$domain='')
[*] {
[*] global $db;
[*] $this->db = &$db;
[*] $this->wd=$wd;
[*] require "../include/splitword.func.php";
[*] $sp = new SplitWord();
[*] $wd_split = $sp->SplitRMM($wd);
[*] $sp->Clear();
[*] $this->wd_split=$wd_split = ereg_replace("[ ]{1,}"," ",trim($wd_split));
[*] $this->wd_array=$wd_array=explode(" ",$wd_split);
[*] $this->wd_count=$wd_count=count($wd_split);//echo $wd_count;
[*] $tgarray=$this->GetTg();
[*] $tgarray_count=count($tgarray);
[*] $ordersql=" order bylinks.tuiguang desc,(";
[*] foreach($wd_array as $value)
[*] {
[*] $ordersql.="(case when links.title like '%".$value."%' then 1 else 0 end)+";
[*] }
[*]
[*] $ordersql.="(case when links.title like '%".$wd."%' then 8 else 0 end)";
[*] // $ordersql=rtrim($ordersql,"+");
[*] $ordersql.=") desc";
[*] $keywordsql=$this->GetKeywordSql("links.title,' ',links.url");
[*] if(empty($keywordsql))
[*] {
[*] $keywordsql="links.title like '%".$wd."%'";
[*] }
[*] if(empty($domain))
[*] {
[*] $sql="select links.*,sites.qp from ve123_links links left join ve123_sites sites on links.site_id=sites.site_id where links.title'' and ".$keywordsql.$ordersql;
[*] }
[*] else
[*] {
[*] if($domain==getdomain($domain))
[*] {
[*] $sql="select * from ve123_links where title'' and url like '%.".$domain."%' or url like '%//".$domain."%'"; //echo $sql;
[*] }
[*] else
[*] {
[*] $sql="select * from ve123_links where title'' and url regexp 'http://".$domain."'";//echo $sql;
[*] }
[*] }
[*] //echo $sql;
[*] $query=$db->query($sql);
[*] $this->total=$total=$db->num_rows($query)+$tgarray_count;
[*] $pagesize=10;
[*] $this->totalpage=$totalpage=ceil($total/$pagesize);
[*] $p=intval($_GET["p"]);
[*] if($pquery($sql." limit $offset,$pagesize");
[*] while($row=$db->fetch_array($query))
[*] {
[*] $data["title"]=$this->GetRedKeyWord(str_cut($row["title"],50));
[*] if(!$row["description"])$row["description"] = $row["fulltxt"];
[*] $data["txt"]=$this->GetRedKeyWord(str_cut($row["description"],250));
[*] $data["url"]=str_cut($row["url"],400);
[*] $data["updatetime"]=date("Y-m-d",$row["updatetime"]);
[*] $data["pagesize"]=$row["pagesize"];
[*] $data["link_id"]=$row["link_id"];
[*] $data["tuiguang"]=$row["tuiguang"];
[*] $array[] = $data;
[*] }
[*]
[*] $array_count=count($array);
[*] if(empty($array_count))
[*] {
[*] $newarray=$tgarray;
[*] }
[*] elseif($p==1&&$tgarray_count>0)
[*] {
[*] $newarray=array_merge($tgarray,$array);
[*] }
[*] else
[*] {
[*] $newarray=$array;
[*] }
[*] return $newarray;
[*] }复制代码基于mysql like和联表的查询,表连myisam的fulltext索引都不加,用这东西会死人的......
sweat.gif
[ 本帖最后由 Kokgog 于 2011-2-27 18:56 编辑 ] 哈哈哈哈。 搜索 做不了 玩玩的话可以考虑用heritrix当爬虫,用coreseek当搜索中间件,比这东西靠谱多了....
页:
[1]