浅析DedeCMS GBK版安装sphinx全文索引无法查询无结果的解决方法
<span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>本测试安装的是sphinx中文版-coreseek 4.0版,用测试中文的命令在命令行查询: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><font color="#ff0000" style='line-height: 25.2px; font-size: 14px; font-family: tahoma, arial, "Microsoft YaHei";'>echo 网络搜索 | iconv -f gbk -t utf-8 | search -c D:\webserver\coreseek-4.0.1-win32\etc\csft_dedecmsv57.conf --stdin | iconv -f utf-8 -t gbk </font><br><br><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>可成功查询。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>但在DedeCms中却无结果,经过摸索,终于找到原因,DedeCMS GBK版的search.php中的关键字编辑是GBK的,而sphinx全文索引要求是utf8, </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>所以无法查询GBK编码的中文; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>解决方法: </strong><br><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>打开plus中的search.php , 找到: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><font color="#ff0000" style='line-height: 25.2px; font-size: 14px; font-family: tahoma, arial, "Microsoft YaHei";'>$keyword = addslashes(cn_substr($keyword,30)); </font><br><br><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在这行下面增加: </strong><br><font color="#ff0000" style='line-height: 25.2px; font-size: 14px; font-family: tahoma, arial, "Microsoft YaHei";'>$keyword= mb_convert_encoding($keyword,"UTF-8", "GBK"); </font><br><br><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>即可正常查询! </span>
頁:
[1]