在网站中都有很多的tag,在做搜索功能的时候一定要提升搜索的智能化,这样才能让搜索的结果更加准确,尽可能精准的找到我们想要的结果。
找到/plus/search.php将其中58行代码:
foreach($typeArr as $id=>$typename) { $keywordn = str_replace($typename, ' ', $keyword); if($keyword != $keywordn) {
修改为:
foreach($typeArr as $id=>$typename)
{
//$keywordn = str_replace($typename, ' ', $keyword);
$keywordn = $keyword;
if($keyword != $keywordn)
{找到/include/arc.searchview.class.php,找到function GetKeywords($keyword)这个类的方法,替换为:
function GetKeywords($keyword)
{
global $cfg_soft_lang;
$keyword = cn_substr($keyword, 50);
$row = $this->dsql->GetOne("SELECT spwords FROM `dede_search_keywords` WHERe keyword='".addslashes($keyword)."'; ");
if(!is_array($row))
{
if(strlen($keyword)>7)
{
$sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
$sp->SetSource($keyword, $cfg_soft_lang, $cfg_soft_lang);
$sp->SetResultType(2);
$sp->StartAnalysis(TRUE);
$keywords = $sp->GetFinallyResult();
$idx_keywords = $sp->GetFinallyIndex();
ksort($idx_keywords);
$keywords = $keyword.' ';
foreach ($idx_keywords as $key => $value) {
if (strlen($key) <= 3) {
continue;
}
$keywords .= ' '.$key;
}
$keywords = preg_replace("/[ ]{1,}/", " ", $keywords);
//var_dump($idx_keywords);exit();
unset($sp);
}
else
{
$keywords = $keyword;
}
$inquery = "INSERT INTO `dede_search_keywords`(`keyword`,`spwords`,`count`,`result`,`lasttime`)
VALUES ('".addslashes($keyword)."', '".addslashes($keywords)."', '1', '0', '".time()."'); ";
$this->dsql->ExecuteNoneQuery($inquery);
}
else
{
$this->dsql->ExecuteNoneQuery("UPDATE `dede_search_keywords` SET count=count+1,lasttime='".time()."' WHERe keyword='".addslashes($keyword)."'; ");
$keywords = $row['spwords'];
}
return $keywords;
}
清空下数据表dede_search_keywords,重新构建检索分词结果。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)