设为首页收藏本站

简体中文 繁體中文 English 日本語 Deutsch 한국 사람 بالعربية TÜRKÇE português คนไทย french

搜索
热搜: 活动 交友 discuz

在介绍个这两天折腾的东西phpsou 开源的搜索 [复制链接]
查看:34 | 回复:4

432

主题

2948

回帖

7288

积分

论坛元老

积分
7288
发表于 2011-2-27 18:40:39 | 显示全部楼层 |阅读模式
结果都是淘宝客

89

主题

9361

回帖

1万

积分

论坛元老

积分
19087
发表于 2011-2-27 18:51:45 | 显示全部楼层
[ol]
  • 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 ;[/ol]复制代码[ol]
  •    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 by  links.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;
  •    }[/ol]复制代码基于mysql like和联表的查询,表连myisam的fulltext索引都不加,用这东西会死人的......



    [ 本帖最后由 Kokgog 于 2011-2-27 18:56 编辑 ]
  • 91

    主题

    4681

    回帖

    9715

    积分

    论坛元老

    积分
    9715
    发表于 2011-2-27 18:55:33 | 显示全部楼层
    哈哈哈哈。

    97

    主题

    2146

    回帖

    4673

    积分

    论坛元老

    积分
    4673
    发表于 2011-2-27 19:01:28 | 显示全部楼层
    搜索 做不了

    29

    主题

    1578

    回帖

    3339

    积分

    论坛元老

    积分
    3339
    发表于 2011-2-27 19:02:14 | 显示全部楼层
    玩玩的话可以考虑用heritrix当爬虫,用coreseek当搜索中间件,比这东西靠谱多了....
    您需要登录后才可以回帖 登录 | 立即注册

    论坛客服/商务合作/投诉举报:2171544 (QQ)
    落伍者创建于2001/03/14,本站内容均为会员发表,并不代表落伍立场!
    拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论!
    落伍官方微信:2030286 邮箱:(djfsys@gmail.com|tech@im286.com)
    © 2001-2014

    浙公网安备 33060302000191号

    浙ICP备11034705号 BBS专项电子公告通信管[2010]226号

      落伍法律顾问: ITlaw-庄毅雄

    Archiver|手机版|Discuz! X

    GMT+8, 2026-6-30 13:52 , Processed in 0.013712 second(s), 4 queries , Gzip On, Redis On.

    返回顶部